X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fimport%2Fcurl-util.c;h=d390cfb1f3e5f0978bfdfb075a300cae3d22dcca;hb=1433efd219a6df414a1821b3d3d70d86201ed3e4;hp=6a6b1c00048c7f75b58c4af3fe944f7ddf90e0c6;hpb=5fa89b2cb366d533e56a9b7a9ce548480776f973;p=elogind.git diff --git a/src/import/curl-util.c b/src/import/curl-util.c index 6a6b1c000..d390cfb1f 100644 --- a/src/import/curl-util.c +++ b/src/import/curl-util.c @@ -236,6 +236,7 @@ CurlGlue *curl_glue_unref(CurlGlue *g) { sd_event_source_unref(g->timer); sd_event_unref(g->event); + free(g); return NULL; } @@ -302,7 +303,7 @@ int curl_glue_make(CURL **ret, const char *url, void *userdata) { goto fail; } - useragent = strappenda(program_invocation_short_name, "/" PACKAGE_VERSION); + useragent = strjoina(program_invocation_short_name, "/" PACKAGE_VERSION); if (curl_easy_setopt(c, CURLOPT_USERAGENT, useragent) != CURLE_OK) { r = -EIO; goto fail; @@ -415,29 +416,31 @@ int curl_header_strdup(const void *contents, size_t sz, const char *field, char } int curl_parse_http_time(const char *t, usec_t *ret) { + const char *e; + locale_t loc; struct tm tm; time_t v; assert(t); assert(ret); - RUN_WITH_LOCALE(LC_TIME, "C") { - const char *e; - - /* RFC822 */ - e = strptime(t, "%a, %d %b %Y %H:%M:%S %Z", &tm); - if (!e || *e != 0) - /* RFC 850 */ - e = strptime(t, "%A, %d-%b-%y %H:%M:%S %Z", &tm); - if (!e || *e != 0) - /* ANSI C */ - e = strptime(t, "%a %b %d %H:%M:%S %Y", &tm); - if (!e || *e != 0) - return -EINVAL; - - v = timegm(&tm); - } + loc = newlocale(LC_TIME_MASK, "C", (locale_t) 0); + if (loc == (locale_t) 0) + return -errno; + + /* RFC822 */ + e = strptime_l(t, "%a, %d %b %Y %H:%M:%S %Z", &tm, loc); + if (!e || *e != 0) + /* RFC 850 */ + e = strptime_l(t, "%A, %d-%b-%y %H:%M:%S %Z", &tm, loc); + if (!e || *e != 0) + /* ANSI C */ + e = strptime_l(t, "%a %b %d %H:%M:%S %Y", &tm, loc); + freelocale(loc); + if (!e || *e != 0) + return -EINVAL; + v = timegm(&tm); if (v == (time_t) -1) return -EINVAL;