diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-11-27 11:48:35 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-11-27 11:48:35 +0100 |
commit | 41b5ef1e4cc6a28bd7274a016d83c95a93656248 (patch) | |
tree | a3df43ccbe1498745e84c6ccdc4f8db20e153f02 /src/plugins/scripts | |
parent | 8ba8e625800462b060bc9e0cfc73dd05059c1f59 (diff) | |
download | weechat-41b5ef1e4cc6a28bd7274a016d83c95a93656248.zip |
core: check pointer returned by function localtime
Diffstat (limited to 'src/plugins/scripts')
-rw-r--r-- | src/plugins/scripts/guile/weechat-guile-api.c | 12 | ||||
-rw-r--r-- | src/plugins/scripts/lua/weechat-lua-api.c | 12 | ||||
-rw-r--r-- | src/plugins/scripts/perl/weechat-perl-api.c | 13 | ||||
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 12 | ||||
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 12 | ||||
-rw-r--r-- | src/plugins/scripts/tcl/weechat-tcl-api.c | 15 |
6 files changed, 62 insertions, 14 deletions
diff --git a/src/plugins/scripts/guile/weechat-guile-api.c b/src/plugins/scripts/guile/weechat-guile-api.c index 7467dec7b..f2e1be9dc 100644 --- a/src/plugins/scripts/guile/weechat-guile-api.c +++ b/src/plugins/scripts/guile/weechat-guile-api.c @@ -4706,15 +4706,19 @@ weechat_guile_api_infolist_time (SCM infolist, SCM variable) { char timebuffer[64], *result; time_t time; + struct tm *date_tmp; SCM return_value; API_FUNC(1, "infolist_time", API_RETURN_EMPTY); if (!scm_is_string (infolist) || !scm_is_string (variable)) API_WRONG_ARGS(API_RETURN_EMPTY); + timebuffer[0] = '\0'; time = weechat_infolist_time (script_str2ptr (scm_i_string_chars (infolist)), scm_i_string_chars (variable)); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); @@ -4976,16 +4980,20 @@ weechat_guile_api_hdata_time (SCM hdata, SCM pointer, SCM name) { char timebuffer[64], *result; time_t time; + struct tm *date_tmp; SCM return_value; API_FUNC(1, "hdata_time", API_RETURN_EMPTY); if (!scm_is_string (hdata) || !scm_is_string (pointer) || !scm_is_string (name)) API_WRONG_ARGS(API_RETURN_EMPTY); + timebuffer[0] = '\0'; time = weechat_hdata_time (script_str2ptr (scm_i_string_chars (hdata)), script_str2ptr (scm_i_string_chars (pointer)), scm_i_string_chars (name)); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c index 24ccbce6d..a9d3ed861 100644 --- a/src/plugins/scripts/lua/weechat-lua-api.c +++ b/src/plugins/scripts/lua/weechat-lua-api.c @@ -5179,6 +5179,7 @@ weechat_lua_api_infolist_time (lua_State *L) { const char *infolist, *variable; time_t time; + struct tm *date_tmp; char timebuffer[64], *result; API_FUNC(1, "infolist_time", API_RETURN_EMPTY); @@ -5188,9 +5189,12 @@ weechat_lua_api_infolist_time (lua_State *L) infolist = lua_tostring (lua_current_interpreter, -2); variable = lua_tostring (lua_current_interpreter, -1); + timebuffer[0] = '\0'; time = weechat_infolist_time (script_str2ptr (infolist), variable); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); @@ -5490,6 +5494,7 @@ weechat_lua_api_hdata_time (lua_State *L) { const char *hdata, *pointer, *name; time_t time; + struct tm *date_tmp; char timebuffer[64], *result; API_FUNC(1, "hdata_time", API_RETURN_EMPTY); @@ -5500,10 +5505,13 @@ weechat_lua_api_hdata_time (lua_State *L) pointer = lua_tostring (lua_current_interpreter, -2); name = lua_tostring (lua_current_interpreter, -1); + timebuffer[0] = '\0'; time = weechat_hdata_time (script_str2ptr (hdata), script_str2ptr (pointer), name); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/scripts/perl/weechat-perl-api.c b/src/plugins/scripts/perl/weechat-perl-api.c index d02ee2d75..bae033256 100644 --- a/src/plugins/scripts/perl/weechat-perl-api.c +++ b/src/plugins/scripts/perl/weechat-perl-api.c @@ -4922,6 +4922,7 @@ XS (XS_weechat_api_infolist_pointer) XS (XS_weechat_api_infolist_time) { time_t time; + struct tm *date_tmp; char timebuffer[64], *result, *infolist, *variable; dXSARGS; @@ -4931,8 +4932,12 @@ XS (XS_weechat_api_infolist_time) infolist = SvPV_nolen (ST (0)); variable = SvPV_nolen (ST (1)); + + timebuffer[0] = '\0'; time = weechat_infolist_time (script_str2ptr (infolist), variable); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); @@ -5224,6 +5229,7 @@ XS (XS_weechat_api_hdata_pointer) XS (XS_weechat_api_hdata_time) { time_t time; + struct tm *date_tmp; char timebuffer[64], *result, *hdata, *pointer, *name; dXSARGS; @@ -5235,10 +5241,13 @@ XS (XS_weechat_api_hdata_time) pointer = SvPV_nolen (ST (1)); name = SvPV_nolen (ST (2)); + timebuffer[0] = '\0'; time = weechat_hdata_time (script_str2ptr (hdata), script_str2ptr (pointer), name); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 18b826ee6..c02716c73 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -5104,6 +5104,7 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args) { char *infolist, *variable, timebuffer[64], *result; time_t time; + struct tm *date_tmp; PyObject *return_value; API_FUNC(1, "infolist_time", API_RETURN_EMPTY); @@ -5112,9 +5113,12 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &infolist, &variable)) API_WRONG_ARGS(API_RETURN_EMPTY); + timebuffer[0] = '\0'; time = weechat_infolist_time (script_str2ptr (infolist), variable); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); @@ -5405,6 +5409,7 @@ weechat_python_api_hdata_time (PyObject *self, PyObject *args) { char *hdata, *pointer, *name, timebuffer[64], *result; time_t time; + struct tm *date_tmp; PyObject *return_value; API_FUNC(1, "hdata_time", API_RETURN_EMPTY); @@ -5414,10 +5419,13 @@ weechat_python_api_hdata_time (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name)) API_WRONG_ARGS(API_RETURN_EMPTY); + timebuffer[0] = '\0'; time = weechat_hdata_time (script_str2ptr (hdata), script_str2ptr (pointer), name); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 5d9b0478b..3ffb20bdf 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -5857,6 +5857,7 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable) { char *c_infolist, *c_variable, timebuffer[64], *result; time_t time; + struct tm *date_tmp; VALUE return_value; API_FUNC(1, "infolist_time", API_RETURN_EMPTY); @@ -5869,8 +5870,11 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable) c_infolist = StringValuePtr (infolist); c_variable = StringValuePtr (variable); + timebuffer[0] = '\0'; time = weechat_infolist_time (script_str2ptr (c_infolist), c_variable); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); @@ -6221,6 +6225,7 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer, { char *c_hdata, *c_pointer, *c_name, timebuffer[64], *result; time_t time; + struct tm *date_tmp; VALUE return_value; API_FUNC(1, "hdata_time", API_RETURN_EMPTY); @@ -6235,10 +6240,13 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer, c_pointer = StringValuePtr (pointer); c_name = StringValuePtr (name); + timebuffer[0] = '\0'; time = weechat_hdata_time (script_str2ptr (c_hdata), script_str2ptr (c_pointer), c_name); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); diff --git a/src/plugins/scripts/tcl/weechat-tcl-api.c b/src/plugins/scripts/tcl/weechat-tcl-api.c index 6f963a1ff..c8f797185 100644 --- a/src/plugins/scripts/tcl/weechat-tcl-api.c +++ b/src/plugins/scripts/tcl/weechat-tcl-api.c @@ -5607,6 +5607,7 @@ weechat_tcl_api_infolist_time (ClientData clientData, Tcl_Interp *interp, { Tcl_Obj *objp; time_t time; + struct tm *date_tmp; char timebuffer[64], *result, *infolist, *variable; int i; @@ -5616,9 +5617,12 @@ weechat_tcl_api_infolist_time (ClientData clientData, Tcl_Interp *interp, infolist = Tcl_GetStringFromObj (objv[1], &i); variable = Tcl_GetStringFromObj (objv[2], &i); - time = weechat_infolist_time (script_str2ptr (infolist), variable); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); + timebuffer[0] = '\0'; + time = weechat_infolist_time (script_str2ptr (infolist), variable); + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); @@ -5921,6 +5925,7 @@ weechat_tcl_api_hdata_time (ClientData clientData, Tcl_Interp *interp, { Tcl_Obj *objp; time_t time; + struct tm *date_tmp; char timebuffer[64], *result, *hdata, *pointer, *name; int i; @@ -5932,11 +5937,13 @@ weechat_tcl_api_hdata_time (ClientData clientData, Tcl_Interp *interp, pointer = Tcl_GetStringFromObj (objv[2], &i); name = Tcl_GetStringFromObj (objv[3], &i); + timebuffer[0] = '\0'; time = weechat_hdata_time (script_str2ptr (hdata), script_str2ptr (pointer), name); - strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time)); - + date_tmp = localtime (&time); + if (date_tmp) + strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp); result = strdup (timebuffer); API_RETURN_STRING_FREE(result); |