diff options
| author | Ben Pfaff <blp@nicira.com> | 2013-05-02 16:16:06 -0700 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2013-05-08 10:53:07 -0700 |
| commit | 3e78870d0bfc3be3255a7ca71588692c6615f0c7 (patch) | |
| tree | 1873dd1ea456a382c7723d39fd5429fb1e992566 /lib/dynamic-string.h | |
| parent | dd43a558597bbf99a62541bc77e85f86f63e2f12 (diff) | |
| download | openvswitch-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 'lib/dynamic-string.h')
| -rw-r--r-- | lib/dynamic-string.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/dynamic-string.h b/lib/dynamic-string.h index 098caafe7..b988e1f2d 100644 --- a/lib/dynamic-string.h +++ b/lib/dynamic-string.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,10 +22,9 @@ #include <stddef.h> #include <stdint.h> #include <stdio.h> +#include <time.h> #include "compiler.h" -struct tm; - /* A "dynamic string", that is, a buffer that can be used to construct a * string across a series of operations that extend or modify it. * @@ -56,14 +55,17 @@ void ds_put_format(struct ds *, const char *, ...) PRINTF_FORMAT(2, 3); void ds_put_format_valist(struct ds *, const char *, va_list) PRINTF_FORMAT(2, 0); void ds_put_printable(struct ds *, const char *, size_t); -void ds_put_strftime(struct ds *, const char *, bool utc) - STRFTIME_FORMAT(2); void ds_put_hex_dump(struct ds *ds, const void *buf_, size_t size, uintptr_t ofs, bool ascii); int ds_get_line(struct ds *, FILE *); int ds_get_preprocessed_line(struct ds *, FILE *); int ds_get_test_line(struct ds *, FILE *); +void ds_put_strftime(struct ds *, const char *template, time_t when, bool utc) + STRFTIME_FORMAT(2); +char *xastrftime(const char *template, time_t when, bool utc) + STRFTIME_FORMAT(1); + char *ds_cstr(struct ds *); const char *ds_cstr_ro(const struct ds *); char *ds_steal_cstr(struct ds *); |
