Support
Quality
Security
License
Reuse
kandi has reviewed curl-android and discovered the below as its top functions. This is intended to give you an instant insight into curl-android implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
generate libc, libssl, liblog, and so shell> make libssl liblog
edit jni/configure.sh, change the default settings: read the script carefully..normally you can keep it as is
run curl-android/jni/configure.sh if there are any error, check and fix...
generate libcurl shell> ndk-build ANDROID_SOURCE=$ANDROID_SOURCE
strip debug from libcurl shell> arm-eabi-strip -g /path/to/libcurl.so
QUESTION
libcurl cookie expiry on android
Asked 2019-Jul-03 at 14:45I am seeing weird behavior with libcurls cookie engine under android, while it works properly in iOS.
The parsing of the cookies expiry date seems not to work in Android when the expiry year is 2038 or higher. I am aware of the int overflow problem with unix timestamps, but that should only occur on January 19th of 2038. With libcurl, as soon as I go to January 1st 2038 00:00 AM the issue occurs.
The following is not the exact original code, because that is more complex. But the cookie strings and curl calls are exactly the same.
// ...create the curl handle...
// Add test cookies in Set-Cookie syntax, because the issue seems to have to do with expiry parsing
static const std::string border = "Tue, 19-Jan-2087 03:14:08 GMT";
static const std::string borderP1 = "Fri, 01-Jan-2038 00:00:00 GMT";
static const std::string borderM1 = "Thu, 31-Dec-2037 23:59:59 GMT";
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, ("Set-Cookie: my1=border;Domain=10.101.32.24;Path=/;Expires=" + border).c_str());
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, ("Set-Cookie: my2=borderP1;Domain=10.101.32.24;Path=/;Expires=" + borderP1).c_str());
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, ("Set-Cookie: my3=borderM1;Domain=10.101.32.24;Path=/;Expires=" + borderM1).c_str());
// Add another cookie in netscape syntax to compare (this one expires on July 10, 3145 9:20:00 AM)
curl_easy_setopt(curlHandle, CURLOPT_COOKIELIST, "10.101.32.24\tFALSE\t/\tFALSE\t37095873600\ttest\tcookie")
// Code to print all cookies known to curl for test purposes:
struct curl_slist *cookies;
curl_easy_getinfo(curlHandle, CURLINFO_COOKIELIST, &cookies);
for (auto c = cookies; c; c = c->next) {
LogStream::debug("Cookie") << c->data;
}
curl_slist_free_all(cookies);
The resulting lines in the log look like this:
Cookie: 10.101.32.24 FALSE / FALSE 0 my1 border
Cookie: 10.101.32.24 FALSE / FALSE 0 my2 borderP1
Cookie: 10.101.32.24 FALSE / FALSE 2145916799 my3 borderM1
Cookie: 10.101.32.24 FALSE / FALSE 37095873600 test cookie
So for the first 2 cookies, which are year 2038 or older, the expiry results in 0. This means they are treated as session cookies, which is bad for me. Weirdly, this does not seem to be caused by 32 bit int overflow, because with the netscape syntax, much larger expiry values are supported.
I can't share the exact build setup for libcurl, but it was derived from the scripts used here and is still fairly similar: https://github.com/gcesarmza/curl-android-ios . We use this setup to build iOS and Android binaries of libcurl (version 7.62.0). Again, with the iOS binaries it works fine (all cookies have correct expiry).
In the actual code I also validate the return of curl_easy_setopt
and it's successfull. If you need more of the setup code I can try to put together a more complete example, but it will take a bit of time.
Does anyone know what could cause this?
ANSWER
Answered 2019-Jul-03 at 14:45curl_setopt
calls Curl_cookie_add
, which in turn calls curl_getdate
for "Set-Cookie"-style input.
This function eventually ends up here with the following code:
/* a signed 32 bit time_t can only hold dates to the beginning of 2038 */
if(yearnum > 2037) {
*output = TIME_T_MAX;
return PARSEDATE_LATER;
}
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Find more information at:
Save this library and start creating your kit
See Similar Libraries in
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source