I did this
I compiled libcurl statically with OpenSSL 1.1.1w (linked dynamically) by using CMake and Embarcadero bcc32 v. 7.0 compiler.
To do this I had to make some minor corrections in the code that are not related with the issue:
In file curl_setup.h I defined:
struct _stati64
{
unsigned int st_dev;
short st_ino; /* Always zero ? */
unsigned short st_mode; /* See above constants */
short st_nlink; /* Number of links. */
short st_uid; /* User: Maybe significant on NT ? */
short st_gid; /* Group: Ditto */
unsigned int st_rdev; /* Seems useless (not even filled in) */
__int64 st_size; /* File size in bytes */
time_t st_atime; /* Access time (always 00:00 on FAT) */
time_t st_mtime; /* Modified time */
time_t st_ctime; /* Creation time */
};
In file vtls.c I added
#undef random
before function Curl_ssl_random.
in file openssl.c I added pragmas for linker:
#pragma comment(lib, "bcrypt.lib")
#pragma comment(lib, "Wldap32.lib")
#pragma comment(lib, "c:\Libs\common\libssle-1_1.lib")
#pragma comment(lib, "c:\Libs\common\libcryptoe-1_1.lib")
where openssl libs were converted to bcc32 OMF linker format by commands:
implib -a libcryptoe-1_1.lib libcrypto-1_1.dll
implib -a libssle-1_1.lib libssl-1_1.dll
In files objects1.rsp (generated by CMake) I replaced UNIX path separators / by Windows path separators \
I expected the following
I expected my app to download a car report from historiapojazdu.gov.pl (polish Central Vehicle Register). But it crashed with code C0000005.
I managed to find the cause: function parsefmt defined in file mprintf.c cannot parse the substring "%I64d" when macro MP_HAVE_INT_EXTENSIONS is not defined. And by default, it is not defined!
So this function ignored "%I64d" and set the type FORMAT_STRING in va_input.type, then wrote value hex: 7FFFFFFF (cookie expiration date) to va_input.val.str by the code:
switch(iptr->type) {
case FORMAT_STRING:
iptr->val.str = va_arg(arglist, char *);
break;
And it caused a crash when accessing this invalid pointer.
The following parser code depends on macro MP_HAVE_INT_EXTENSIONS :
file mprintf.c
line 350
#if defined(MP_HAVE_INT_EXTENSIONS)
case 'I':
if((fmt[0] == '3') && (fmt[1] == '2')) {
flags |= FLAGS_LONG;
fmt += 2;
}
else if((fmt[0] == '6') && (fmt[1] == '4')) {
flags |= FLAGS_LONGLONG;
fmt += 2;
}
else {
#if (SIZEOF_CURL_OFF_T > SIZEOF_LONG)
flags |= FLAGS_LONGLONG;
#else
flags |= FLAGS_LONG;
#endif
}
break;
#endif
curl/libcurl version
curl 8.6.0 (I built libcurl.lib only, no curl.exe because of linker error Unresolved external '_main' and because I don't need it).
operating system
Windows 10 Professional
I did this
I compiled libcurl statically with OpenSSL 1.1.1w (linked dynamically) by using CMake and Embarcadero bcc32 v. 7.0 compiler.
To do this I had to make some minor corrections in the code that are not related with the issue:
In file curl_setup.h I defined:
In file vtls.c I added
#undef randombefore function Curl_ssl_random.
in file openssl.c I added pragmas for linker:
where openssl libs were converted to bcc32 OMF linker format by commands:
In files objects1.rsp (generated by CMake) I replaced UNIX path separators / by Windows path separators \
I expected the following
I expected my app to download a car report from historiapojazdu.gov.pl (polish Central Vehicle Register). But it crashed with code C0000005.
I managed to find the cause: function parsefmt defined in file mprintf.c cannot parse the substring "%I64d" when macro MP_HAVE_INT_EXTENSIONS is not defined. And by default, it is not defined!
So this function ignored "%I64d" and set the type FORMAT_STRING in va_input.type, then wrote value hex: 7FFFFFFF (cookie expiration date) to va_input.val.str by the code:
And it caused a crash when accessing this invalid pointer.
The following parser code depends on macro MP_HAVE_INT_EXTENSIONS :
file mprintf.c
line 350
curl/libcurl version
curl 8.6.0 (I built libcurl.lib only, no curl.exe because of linker error Unresolved external '_main' and because I don't need it).
operating system
Windows 10 Professional