Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit ceaa87d

Browse files
committed
Merge branch 'release-6.6.3' into develop
Conflicts: engine/engine.xcodeproj/project.pbxproj engine/src/util.cpp
2 parents d0ca68d + 9ca58e5 commit ceaa87d

File tree

7 files changed

+78
-44
lines changed

7 files changed

+78
-44
lines changed

docs/notes/bugfix-13038.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# uuid: not enough randomness available

docs/notes/bugfix-13096.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Answer files with relative path

engine/engine.xcodeproj/project.pbxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@
549549
E8AE876C177B3F5C0041B7E0 /* cgimageutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8AE876B177B3F5C0041B7E0 /* cgimageutil.cpp */; };
550550
E8AF465B174CF247000B2F9E /* surface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D4F9DFA13CDE63000B9B15D /* surface.cpp */; };
551551
E8B5BB1416DF77DF00CA02FB /* imagelist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8B5BB1216DF77DF00CA02FB /* imagelist.cpp */; };
552+
E8D1ECDD1992395A00984EFE /* sysosxrandom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DB32230174BD08E00046FFE /* sysosxrandom.cpp */; };
552553
E8D7F8321785A88200EC051A /* imagelist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8B5BB1216DF77DF00CA02FB /* imagelist.cpp */; };
553554
E8D7F8391785A8AC00EC051A /* graphicscontext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C10D76D16BF9BFA00D25197 /* graphicscontext.cpp */; };
554555
E8D7F8471785A99900EC051A /* srvtheme.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E8D7F8461785A99900EC051A /* srvtheme.cpp */; };
@@ -3455,6 +3456,7 @@
34553456
4D1F9D28171C682E0091C6CB /* button.cpp in Sources */,
34563457
4D1F9D29171C682E0091C6CB /* card.cpp in Sources */,
34573458
4D1F9D2A171C682E0091C6CB /* cardlst.cpp in Sources */,
3459+
E8D1ECDD1992395A00984EFE /* sysosxrandom.cpp in Sources */,
34583460
4D1F9D2B171C682E0091C6CB /* cdata.cpp in Sources */,
34593461
4D1F9D2C171C682E0091C6CB /* chunk.cpp in Sources */,
34603462
4D1F9D2D171C682E0091C6CB /* cmds.cpp in Sources */,
@@ -3593,7 +3595,6 @@
35933595
4D1F9DB2171C682E0091C6CB /* irle.cpp in Sources */,
35943596
4D1F9DB3171C682E0091C6CB /* stackcache.cpp in Sources */,
35953597
4D1F9DB4171C682E0091C6CB /* stacksecurity.cpp in Sources */,
3596-
4DB32401174BEE1400046FFE /* sysunxrandom.cpp in Sources */,
35973598
4DB32402174BEE1900046FFE /* uuid.cpp in Sources */,
35983599
E8D7F8321785A88200EC051A /* imagelist.cpp in Sources */,
35993600
4C885A0F1940C6D40040DF0B /* coretextfonts.cpp in Sources */,

engine/src/answer.cpp

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
4242
#include "answer.h"
4343
#include "printer.h"
4444

45+
#include "osspec.h"
46+
4547
const char *MCdialogtypes[] =
4648
{
4749
"plain",
@@ -494,6 +496,17 @@ Exec_errors MCAnswer::exec_file(MCExecPoint& ep, const char *p_title)
494496
if (!t_error && !MCSecureModeCanAccessDisk())
495497
t_error = EE_DISK_NOPERM;
496498

499+
char *t_initial_resolved;
500+
t_initial_resolved = nil;
501+
502+
if (!t_error && t_initial != nil)
503+
{
504+
// IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
505+
t_initial_resolved = MCS_get_canonical_path(t_initial);
506+
if (nil == t_initial_resolved)
507+
t_error == EE_NO_MEMORY;
508+
}
509+
497510
if (!t_error)
498511
{
499512
if (MCsystemFS && MCscreen -> hasfeature ( PLATFORM_FEATURE_OS_FILE_DIALOGS ) )
@@ -505,23 +518,26 @@ Exec_errors MCAnswer::exec_file(MCExecPoint& ep, const char *p_title)
505518
t_options |= MCA_OPTION_PLURAL;
506519

507520
if (t_types != NULL)
508-
MCA_file_with_types(ep, p_title, t_prompt, t_type_strings, t_type_count, t_initial, t_options);
521+
MCA_file_with_types(ep, p_title, t_prompt, t_type_strings, t_type_count, t_initial_resolved, t_options);
509522
else
510-
MCA_file(ep, p_title, t_prompt, t_filter, t_initial, t_options);
523+
MCA_file(ep, p_title, t_prompt, t_filter, t_initial_resolved, t_options);
511524
}
512525
else
513526
{
514527
MCExecPoint ep2(ep);
515528
ep2 . clear();
516529
for(uint4 t_type = 0; t_type < t_type_count; ++t_type)
517530
ep2 . concatcstring(t_type_strings[t_type], EC_RETURN, t_type == 0);
518-
t_error = exec_custom(ep, MCfsnamestring, mode == AT_FILE ? "file" : "files", 5, p_title, *t_prompt, *t_filter, *t_initial, ep2 . getsvalue() . getstring());
531+
t_error = exec_custom(ep, MCfsnamestring, mode == AT_FILE ? "file" : "files", 5, p_title, *t_prompt, *t_filter, t_initial_resolved, ep2 . getsvalue() . getstring());
519532
}
520533

521534
if (ep . getsvalue() == MCnullmcstring && t_types == NULL)
522535
MCresult -> sets(MCcancelstring);
523536
}
524537

538+
if (t_initial_resolved != nil)
539+
MCCStringFree(t_initial_resolved);
540+
525541
delete[] t_types;
526542
delete t_type_strings;
527543

@@ -546,6 +562,17 @@ Exec_errors MCAnswer::exec_folder(MCExecPoint& ep, const char *p_title)
546562
if (!t_error && !MCSecureModeCanAccessDisk())
547563
t_error = EE_DISK_NOPERM;
548564

565+
char *t_initial_resolved;
566+
t_initial_resolved = nil;
567+
568+
if (!t_error && t_initial != nil)
569+
{
570+
// IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
571+
t_initial_resolved = MCS_get_canonical_path(t_initial);
572+
if (nil == t_initial_resolved)
573+
t_error == EE_NO_MEMORY;
574+
}
575+
549576
if (!t_error)
550577
{
551578
unsigned int t_options = 0;
@@ -555,14 +582,17 @@ Exec_errors MCAnswer::exec_folder(MCExecPoint& ep, const char *p_title)
555582
t_options |= MCA_OPTION_PLURAL;
556583

557584
if (MCsystemFS)
558-
MCA_folder(ep, p_title, t_prompt, t_initial, t_options);
585+
MCA_folder(ep, p_title, t_prompt, t_initial_resolved, t_options);
559586
else
560-
t_error = exec_custom(ep, MCfsnamestring, mode == AT_FOLDER ? "folder" : "folders", 4, p_title, *t_prompt, NULL, *t_initial);
587+
t_error = exec_custom(ep, MCfsnamestring, mode == AT_FOLDER ? "folder" : "folders", 4, p_title, *t_prompt, NULL, t_initial_resolved);
561588

562589
if (ep . getsvalue() == MCnullmcstring)
563590
MCresult -> sets(MCcancelstring);
564591
}
565592

593+
if (t_initial_resolved != nil)
594+
MCCStringFree(t_initial_resolved);
595+
566596
return t_error;
567597
}
568598
#endif /* MCAnswer::exec_folder */

engine/src/ask.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
3737
#include "dispatch.h"
3838
#include "securemode.h"
3939

40+
#include "osspec.h"
41+
4042
#include "globals.h"
4143

4244
#include "meta.h"
@@ -366,6 +368,17 @@ Exec_errors MCAsk::exec_file(MCExecPoint& ep, const char *p_title)
366368
if (!t_error && !MCSecureModeCanAccessDisk())
367369
t_error = EE_DISK_NOPERM;
368370

371+
char *t_initial_resolved;
372+
t_initial_resolved = nil;
373+
374+
if (!t_error && t_initial != nil)
375+
{
376+
// IM-2014-08-06: [[ Bug 13096 ]] Allow file dialogs to work with relative paths by resolving to absolute
377+
t_initial_resolved = MCS_get_canonical_path(t_initial);
378+
if (nil == t_initial_resolved)
379+
t_error == EE_NO_MEMORY;
380+
}
381+
369382
if (!t_error)
370383
{
371384
if (MCsystemFS)
@@ -375,9 +388,9 @@ Exec_errors MCAsk::exec_file(MCExecPoint& ep, const char *p_title)
375388
t_options |= MCA_OPTION_SHEET;
376389

377390
if (t_types != NULL)
378-
MCA_ask_file_with_types(ep, p_title, t_prompt, t_type_strings, t_type_count, t_initial, t_options);
391+
MCA_ask_file_with_types(ep, p_title, t_prompt, t_type_strings, t_type_count, t_initial_resolved, t_options);
379392
else
380-
MCA_ask_file(ep, p_title, t_prompt, t_filter, t_initial, t_options);
393+
MCA_ask_file(ep, p_title, t_prompt, t_filter, t_initial_resolved, t_options);
381394
}
382395
else
383396
{
@@ -386,13 +399,16 @@ Exec_errors MCAsk::exec_file(MCExecPoint& ep, const char *p_title)
386399
ep2 . clear();
387400
for(uint4 t_type = 0; t_type < t_type_count; ++t_type)
388401
ep2 . concatcstring(t_type_strings[t_type], EC_RETURN, t_type == 0);
389-
t_error = exec_custom(ep, t_cancelled, MCfsnamestring, mode == AT_FILE ? "file" : "files", 5, p_title, *t_prompt, *t_filter, *t_initial, ep2 . getsvalue() . getstring());
402+
t_error = exec_custom(ep, t_cancelled, MCfsnamestring, mode == AT_FILE ? "file" : "files", 5, p_title, *t_prompt, *t_filter, t_initial_resolved, ep2 . getsvalue() . getstring());
390403
}
391404

392405
if (ep . getsvalue() == MCnullmcstring && t_types == NULL)
393406
MCresult -> sets(MCcancelstring);
394407
}
395408

409+
if (t_initial_resolved != nil)
410+
MCCStringFree(t_initial_resolved);
411+
396412
delete[] t_types;
397413
delete t_type_strings;
398414

engine/src/sysosxrandom.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@
2121
#include "filedefs.h"
2222
#include "objdefs.h"
2323
#include "parsedef.h"
24+
#include "globals.h"
2425

25-
#include "mcssl.h"
26+
#include <Carbon/Carbon.h>
27+
28+
typedef const struct __SecRandom * SecRandomRef;
29+
#define kSecRandomDefault (NULL)
30+
31+
typedef int (*SecRandomCopyBytesPtr)(SecRandomRef p_rnd, size_t p_count, uint8_t *p_bytes);
32+
33+
static SecRandomCopyBytesPtr s_sec_random_copy_bytes = nil;
2634

2735
////////////////////////////////////////////////////////////////////////////////
2836

2937
// MW-2013-05-21: [[ RandomBytes ]] Implementation of random byte generation for
3038
// Mac (Desktop and Server).
3139
bool MCS_random_bytes(size_t p_count, void *p_buffer)
3240
{
33-
// On Mac (both Server and Desktop) OpenSSL is always available so we will
34-
// never get here.
35-
return false;
36-
}
37-
38-
////////////////////////////////////////////////////////////////////////////////
39-
40-
// This is alternative code which doesn't rely on OpenSSL (not needed now, but
41-
// maybe in the future).
42-
#if 0
43-
{
41+
// IM-2014-08-06: [[ Bug 13038 ]] Enable this implementation on OSX + server
42+
// so we can remove the reliance on SSL from MCU_random_bytes
43+
4444
// Now, on Lion and above SecRandomCopyBytes is available, so use that if
4545
// possible. ( Note that as we can't link against the 10.7 SDK, we have to
4646
// weak-link manually :( ).
@@ -49,17 +49,18 @@ bool MCS_random_bytes(size_t p_count, void *p_buffer)
4949
if (s_sec_random_copy_bytes == nil)
5050
{
5151
CFBundleRef t_security_bundle;
52-
t_security_bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Security"));
52+
t_security_bundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.security"));
5353
if (t_security_bundle != nil)
5454
{
55-
s_sec_random_copy_bytes = (SecRandomCopyBytesPtr)CFBundleGetFunctionPointerForName(t_security_bundle, CFSTR("SetRandomCopyBytes"));
55+
s_sec_random_copy_bytes = (SecRandomCopyBytesPtr)CFBundleGetFunctionPointerForName(t_security_bundle, CFSTR("SecRandomCopyBytes"));
5656
CFRelease(t_security_bundle);
5757
}
5858
}
5959

6060
if (s_sec_random_copy_bytes != nil)
61-
return s_sec_random_copy_bytes(NULL, p_count, (uint8_t *)p_buffer);
62-
}
61+
// IM-2014-04-16: [[ Bug 11860 ]] SecRandomCopyBytes returns 0 on success
62+
return 0 == s_sec_random_copy_bytes(NULL, p_count, (uint8_t *)p_buffer);
63+
}
6364

6465
// Otherwise attempt to use /dev/urandom
6566
int t_fd;
@@ -96,6 +97,5 @@ bool MCS_random_bytes(size_t p_count, void *p_buffer)
9697
// If we read the correct number of bytes, then we are done.
9798
return t_bytes_read == p_count;
9899
}
99-
#endif
100100

101101
////////////////////////////////////////////////////////////////////////////////

engine/src/util.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
4141

4242
#include "globals.h"
4343

44-
#ifdef MCSSL
45-
#include <openssl/rand.h>
46-
#endif
4744

4845
// MDW-2014-07-06: [[ oval_points ]]
4946
#define QA_NPOINTS 90
@@ -2907,23 +2904,10 @@ bool MCU_compare_strings_native(const char *p_a, bool p_a_isunicode, const char
29072904

29082905
///////////////////////////////////////////////////////////////////////////////
29092906

2910-
// MW-2013-05-21: [[ RandomBytes ]] Utility function for generating random bytes
2911-
// which uses OpenSSL if available, otherwise falls back on system support.
2907+
// MW-2013-05-21: [[ RandomBytes ]] Utility function for generating random bytes.
29122908
bool MCU_random_bytes(size_t p_count, void *p_buffer)
29132909
{
2914-
#ifdef MCSSL
2915-
// If SSL is available, then use that.
2916-
static bool s_donotuse_ssl = false;
2917-
if (!s_donotuse_ssl)
2918-
{
2919-
if (InitSSLCrypt())
2920-
return RAND_bytes((unsigned char *)p_buffer, p_count) == 1;
2921-
2922-
s_donotuse_ssl = true;
2923-
}
2924-
#endif
2925-
2926-
// Otherwise use the system provided CPRNG.
2910+
// IM-2014-08-06: [[ Bug 13038 ]] Use system implementation directly instead of SSL
29272911
return MCS_random_bytes(p_count, p_buffer);
29282912
}
29292913

@@ -2950,3 +2934,4 @@ void operator delete[] (void *p)
29502934
free(p);
29512935
}
29522936
#endif
2937+

0 commit comments

Comments
 (0)