summaryrefslogtreecommitdiff
path: root/ovsdb/ovsdb-tool.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2013-05-02 16:16:06 -0700
committerBen Pfaff <blp@nicira.com>2013-05-08 10:53:07 -0700
commit3e78870d0bfc3be3255a7ca71588692c6615f0c7 (patch)
tree1873dd1ea456a382c7723d39fd5429fb1e992566 /ovsdb/ovsdb-tool.c
parentdd43a558597bbf99a62541bc77e85f86f63e2f12 (diff)
downloadopenvswitch-3e78870d0bfc3be3255a7ca71588692c6615f0c7.tar.gz
Always check return value of strftime().
strftime() returns 0 and leaves the contents of the output buffer unspecified if the output buffer is not big enough. Thus, one should check strftime()'s return value. Until now, OVS has had a few invocations of strftime() that did not check the return value. This commit fixes those. I believe that the buffers were always large enough in each case, but it's better to be safe. Reported-by: Andy Zhou <azhou@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'ovsdb/ovsdb-tool.c')
-rw-r--r--ovsdb/ovsdb-tool.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index 2ef4061aa..a8febdabc 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -519,11 +519,9 @@ do_show_log(int argc, char *argv[])
date = shash_find_data(json_object(json), "_date");
if (date && date->type == JSON_INTEGER) {
time_t t = json_integer(date);
- struct tm tm;
- char s[128];
-
- strftime(s, sizeof s, "%Y-%m-%d %H:%M:%S", gmtime_r(&t, &tm));
- printf(" %s", s);
+ char *s = xastrftime(" %Y-%m-%d %H:%M:%S", t, true);
+ fputs(s, stdout);
+ free(s);
}
comment = shash_find_data(json_object(json), "_comment");