{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1752654154,
"reponame":"libwebsockets",
"desc":"libwebsockets lightweight C networking library",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"56687659575beea4e228f744842edb32",
"commit": {"type":"commit",
"time": 1616666920,
"time_ofs": 0,
"oid_tree": { "oid": "316a9b55f4d17282ddba91496bd874cf26aaa87a", "alias": []},
"oid":{ "oid": "f84b90ba03ceb942885d19dd1ad357464addc089", "alias": []},
"msg": "use gmtime_r instead of gmtime if possible",
"sig_commit": { "git_time": { "time": 1616666920, "offset": 0 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1616658661, "offset": 180 }, "name": "Pavel Otchertsov", "email": "pavel.otchertsov@gmail.com", "md5": "e1ac0b2881825960ee59b5922ab07ce7" }},
"body": "use gmtime_r instead of gmtime if possible\n\nAlso check tm result is not NULL before using it.\n"
,
"diff": "diff --git a/CMakeLists.txt b/CMakeLists.txt\nindex a45f92f..e94757c 100644\n--- a/CMakeLists.txt\n+++ b/CMakeLists.txt\n@@ -552,6 +552,7 @@ CHECK_FUNCTION_EXISTS(_atoi64 LWS_HAVE__ATOI64)\n CHECK_FUNCTION_EXISTS(_stat32i64 LWS_HAVE__STAT32I64)\n CHECK_FUNCTION_EXISTS(clock_gettime LWS_HAVE_CLOCK_GETTIME)\n CHECK_FUNCTION_EXISTS(localtime_r LWS_HAVE_LOCALTIME_R)\n+CHECK_FUNCTION_EXISTS(gmtime_r LWS_HAVE_GMTIME_R)\n CHECK_FUNCTION_EXISTS(ctime_r LWS_HAVE_CTIME_R)\n CHECK_FUNCTION_EXISTS(getgrgid_r LWS_HAVE_GETGRGID_R)\n CHECK_FUNCTION_EXISTS(getgrnam_r LWS_HAVE_GETGRNAM_R)\ndiff --git a/cmake/lws_config.h.in b/cmake/lws_config.h.in\nindex ff35308..d74679f 100644\n--- a/cmake/lws_config.h.in\n+++ b/cmake/lws_config.h.in\n@@ -51,6 +51,7 @@\n #cmakedefine LWS_HAVE_EVP_PKEY_new_raw_private_key\n #cmakedefine LWS_HAVE_EXECVPE\n #cmakedefine LWS_HAVE_LOCALTIME_R\n+#cmakedefine LWS_HAVE_GMTIME_R\n #cmakedefine LWS_HAVE_CTIME_R\n #cmakedefine LWS_HAVE_GETGRGID_R\n #cmakedefine LWS_HAVE_GETGRNAM_R\ndiff --git a/lib/roles/http/date.c b/lib/roles/http/date.c\nindex 5928d8c..0b0012b 100644\n--- a/lib/roles/http/date.c\n+++ b/lib/roles/http/date.c\n@@ -53,7 +53,14 @@ lws_http_date_render(char *buf, size_t len, const struct tm *tm)\n int\n lws_http_date_render_from_unix(char *buf, size_t len, const time_t *t)\n {\n+#if defined(LWS_HAVE_GMTIME_R)\n+\tstruct tm tmp;\n+\tstruct tm *tm \u003d gmtime_r(t, \u0026tmp);\n+#else\n \tstruct tm *tm \u003d gmtime(t);\n+#endif\n+\tif (!tm)\n+\t\treturn -1;\n \n \tif (lws_http_date_render(buf, len, tm))\n \t\treturn -1;\ndiff --git a/minimal-examples/secure-streams/minimal-secure-streams-sigv4/ss-s3-ss.c b/minimal-examples/secure-streams/minimal-secure-streams-sigv4/ss-s3-ss.c\nindex a9cce26..b12f8f5 100644\n--- a/minimal-examples/secure-streams/minimal-secure-streams-sigv4/ss-s3-ss.c\n+++ b/minimal-examples/secure-streams/minimal-secure-streams-sigv4/ss-s3-ss.c\n@@ -87,15 +87,15 @@ create_payload(uint8_t *buf, size_t s)\n static void set_time(char *t)\n {\n \t/*20150830T123600Z*/\n-\ttime_t rawtime;\n-\tstruct tm *info;\n-\n-\ttime(\u0026rawtime );\n-\tinfo \u003d gmtime(\u0026rawtime);\n-\n-\tstrftime(t ,20,\u0022%Y%m%dT%H%M%SZ\u0022, info);\n-\n-\treturn;\n+\ttime_t ti \u003d time(NULL);\n+#if defined(LWS_HAVE_GMTIME_R)\n+\tstruct tm tmp;\n+\tstruct tm *tm \u003d gmtime_r(\u0026ti, \u0026tmp);\n+#else\n+\tstruct tm *tm \u003d gmtime(\u0026ti);\n+#endif\n+\tassert(tm);\n+\tstrftime(t, 20, \u0022%Y%m%dT%H%M%SZ\u0022, tm);\n }\n \n static void bin2hex(uint8_t *in, size_t len, char *out)\n","s":{"c":1752654154,"u": 2779}}
],"g": 3358,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}