Skip to content

Commit 00f5fee

Browse files
committed
Merge remote-tracking branch 'origin/develop-7.0' into develop
2 parents 51d8a60 + 14d025b commit 00f5fee

11 files changed

Lines changed: 59 additions & 26 deletions

File tree

docs/notes/bugfix-14452.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix session storage via $_SESSION in CGI mode

docs/notes/bugfix-16940.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix access to https:// URLs from OSX server engines

docs/notes/bugfix-16971.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix a memory leak causing the autoupdater to fail

docs/notes/bugfix-17174.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Use the system certificate store for Win32 server SSL verification

engine/src/mac-core.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -690,21 +690,21 @@ static void runloop_observer(CFRunLoopObserverRef observer, CFRunLoopActivity ac
690690
MCPlatformBreakWait();
691691
}
692692

693-
static bool s_event_checking_enabled = true;
693+
static uindex_t s_event_checking_enabled = 0;
694694

695695
void MCMacPlatformEnableEventChecking(void)
696696
{
697-
s_event_checking_enabled = true;
697+
s_event_checking_enabled += 1;
698698
}
699699

700700
void MCMacPlatformDisableEventChecking(void)
701701
{
702-
s_event_checking_enabled = false;
702+
s_event_checking_enabled -= 1;
703703
}
704704

705705
bool MCMacPlatformIsEventCheckingEnabled(void)
706706
{
707-
return s_event_checking_enabled;
707+
return s_event_checking_enabled == 0;
708708
}
709709

710710
bool MCPlatformWaitForEvent(double p_duration, bool p_blocking)

engine/src/mac-window.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,8 +1739,15 @@ - (void)setFrameSize: (NSSize)size
17391739
MCRectangle t_content;
17401740
MCMacPlatformMapScreenNSRectToMCRectangle(t_new_cocoa_content, t_content);
17411741

1742+
// Make sure we don't tickle the event queue whilst resizing, otherwise
1743+
// redraws can be done by the OS during the process resulting in tearing
1744+
// as the window resizes.
1745+
MCMacPlatformDisableEventChecking();
1746+
17421747
// And get the super class to deal with it.
17431748
HandleReshape(t_content);
1749+
1750+
MCMacPlatformEnableEventChecking();
17441751
}
17451752

17461753
void MCMacPlatformWindow::ProcessDidResize(void)

engine/src/mcssl.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ bool load_ssl_ctx_certs_from_file(SSL_CTX *p_ssl_ctx, const char *p_path)
774774
return SSL_CTX_load_verify_locations(p_ssl_ctx, p_path, NULL) != 0;
775775
}
776776

777-
#if defined(TARGET_PLATFORM_MACOS_X) || defined(TARGET_PLATFORM_WINDOWS)
777+
#if defined(TARGET_PLATFORM_MACOS_X) || defined(_WIN32)
778778

779779
void free_x509_stack(STACK_OF(X509) *p_stack)
780780
{
@@ -958,7 +958,7 @@ bool export_system_crl_stack(STACK_OF(X509_CRL) *&r_crls)
958958
return true;
959959
}
960960

961-
#elif defined(TARGET_PLATFORM_WINDOWS)
961+
#elif defined(_WIN32)
962962

963963
bool export_system_root_cert_stack(STACK_OF(X509) *&r_cert_stack)
964964
{
@@ -981,11 +981,7 @@ bool export_system_root_cert_stack(STACK_OF(X509) *&r_cert_stack)
981981
if (t_valid)
982982
{
983983
X509 *t_x509 = NULL;
984-
#if defined(TARGET_PLATFORM_WINDOWS)
985984
const unsigned char *t_data = (const unsigned char*) t_cert_enum->pbCertEncoded;
986-
#else
987-
unsigned char *t_data = t_cert_enum->pbCertEncoded;
988-
#endif
989985
long t_len = t_cert_enum->cbCertEncoded;
990986

991987
t_success = NULL != (t_x509 = d2i_X509(NULL, &t_data, t_len));
@@ -1027,11 +1023,7 @@ bool export_system_crl_stack(STACK_OF(X509_CRL) *&r_crls)
10271023
if (t_valid)
10281024
{
10291025
X509_CRL *t_crl = NULL;
1030-
#if defined(TARGET_PLATFORM_WINDOWS)
10311026
const unsigned char *t_data = (const unsigned char*)t_crl_enum->pbCrlEncoded;
1032-
#else
1033-
unsigned char *t_data = t_crl_enum->pbCrlEncoded;
1034-
#endif
10351027
long t_len = t_crl_enum->cbCrlEncoded;
10361028

10371029
t_success = NULL != (t_crl = d2i_X509_CRL(NULL, &t_data, t_len));

engine/src/srvcgi.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static MCVariable *s_cgi_files; // ArrayRef
6262
static MCVariable *s_cgi_get; // nativised StringRef
6363
static MCVariable *s_cgi_get_raw; // StringRef
6464
static MCVariable *s_cgi_get_binary; // DataRef
65-
static MCVariable *s_cgi_cookie; // StringRef
65+
static MCVariable *s_cgi_cookie; // ArrayRef
6666

6767
static bool s_cgi_processed_post = false;
6868

@@ -923,6 +923,11 @@ static bool cgi_compute_get_var(void *p_context, MCVariable *p_var)
923923

924924
cgi_store_form_urlencoded(s_cgi_get, *t_query_data, true);
925925
}
926+
else
927+
{
928+
// Set the $_GET variable to the empty array
929+
s_cgi_get->setvalueref(kMCEmptyArray);
930+
}
926931

927932
return true;
928933
}
@@ -957,6 +962,11 @@ static bool cgi_compute_get_binary_var(void *p_context, MCVariable *p_var)
957962

958963
cgi_store_form_urlencoded(s_cgi_get_binary, *t_query_data, true);
959964
}
965+
else
966+
{
967+
// Set the $_GET_BINARY variable to the empty array
968+
s_cgi_get_binary->setvalueref(kMCEmptyArray);
969+
}
960970
return true;
961971
}
962972

@@ -1053,6 +1063,12 @@ static bool cgi_compute_post_variables()
10531063
cgi_store_form_multipart(t_stdin_handle);
10541064
MCS_close(t_stdin_handle);
10551065
}
1066+
else
1067+
{
1068+
// Set the $_POST and $_POST_BINARY variables to empty arrays
1069+
s_cgi_post->setvalueref(kMCEmptyArray);
1070+
s_cgi_post_binary->setvalueref(kMCEmptyArray);
1071+
}
10561072
return t_success;
10571073
}
10581074

@@ -1419,8 +1435,12 @@ static bool cgi_compute_cookie_var(void *p_context, MCVariable *p_var)
14191435
cgi_store_cookie_urlencoded(s_cgi_cookie, *t_query_data, true);
14201436
}
14211437
else
1422-
// returns true if nothing had to be computed
1423-
return true;
1438+
{
1439+
// There is no cookie data so set the variable to the empty array (it
1440+
// needs to be an array rather than the empty type because the rest of
1441+
// the CGI code assumes $_COOKIE holds an array).
1442+
s_cgi_cookie->setvalueref(kMCEmptyArray);
1443+
}
14241444

14251445
return t_success;
14261446
}

engine/src/srvspec.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,14 @@ static void url_execute(MCStringRef p_url, MCUrlExecuteCallback p_callback, void
350350
{
351351
// IM-2014-07-28: [[ Bug 12822 ]] Override default ssl certificate loading.
352352
if (curl_easy_setopt(t_url_handle, CURLOPT_SSL_VERIFYPEER, 1) != CURLE_OK ||
353-
curl_easy_setopt(t_url_handle, CURLOPT_SSL_VERIFYHOST, 2) != CURLE_OK ||
354-
- curl_easy_setopt(t_url_handle, CURLOPT_CAINFO, nil) != CURLE_OK ||
355-
curl_easy_setopt(t_url_handle, CURLOPT_SSL_CTX_FUNCTION, _set_ssl_certificates_callback) != CURLE_OK)
353+
curl_easy_setopt(t_url_handle, CURLOPT_SSL_VERIFYHOST, 2) != CURLE_OK
354+
#if defined(_LINUX) || defined(_WIN32)
355+
// These options are not supported when using the OSX system libcurl
356+
// as it uses the OS' certificate database and not a cert file.
357+
|| curl_easy_setopt(t_url_handle, CURLOPT_CAINFO, nil) != CURLE_OK
358+
|| curl_easy_setopt(t_url_handle, CURLOPT_SSL_CTX_FUNCTION, _set_ssl_certificates_callback) != CURLE_OK
359+
#endif
360+
)
356361
t_error = "couldn't configure ssl";
357362
}
358363

engine/src/variable.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ bool MCVariable::createcopy(MCVariable& p_var, MCVariable*& r_new_var)
110110
return t_success;
111111
}
112112

113-
bool MCVariable::encode(void *&r_buffer, uindex_t r_size)
113+
bool MCVariable::encode(void *&r_buffer, uindex_t& r_size)
114114
{
115115
IO_handle t_stream;
116116
t_stream = MCS_fakeopenwrite();
@@ -221,11 +221,16 @@ bool MCVariable::decode(void *p_buffer, uindex_t p_size)
221221
case kMCEncodedValueTypeLegacyArray:
222222
{
223223
MCAutoArrayRef t_array;
224-
t_stat = MCArrayLoadFromHandleLegacy(&t_array, t_stream);
224+
if (!MCArrayCreateMutable(&t_array))
225+
t_stat = IO_ERROR;
226+
227+
if (t_stat == IO_NORMAL)
228+
t_stat = MCArrayLoadFromHandleLegacy(*t_array, t_stream);
225229

226-
if (t_stat == IO_NORMAL)
227-
/* UNCHECKED */ setvalueref(*t_array);
230+
if (t_stat == IO_NORMAL && !setvalueref(*t_array))
231+
t_stat = IO_ERROR;
228232
}
233+
break;
229234
default:
230235
t_stat = IO_ERROR;
231236
break;
@@ -617,7 +622,7 @@ bool MCVariable::modify_data(MCExecContext& ctxt, MCDataRef p_data, MCNameRef *p
617622
t_value_as_data = nil;
618623
// SN-2014-04-11 [[ FasterVariable ]] now chose between appending or prepending
619624
if (ctxt . ConvertToData(t_current_value, t_value_as_data) &&
620-
MCDataMutableCopy(t_value_as_data, t_value_as_data) &&
625+
MCDataMutableCopyAndRelease(t_value_as_data, t_value_as_data) &&
621626
((p_setting == kMCVariableSetAfter && MCDataAppend(t_value_as_data, p_data)) ||
622627
(p_setting == kMCVariableSetBefore && MCDataPrepend(t_value_as_data, p_data))) &&
623628
setvalueref(p_path, p_length, ctxt . GetCaseSensitive(), t_value_as_data))

0 commit comments

Comments
 (0)