]> granicus.if.org Git - libnl/commitdiff
handle the case where 0 is passed to nl_size2str
authorJoe Damato <ice799@gmail.com>
Sun, 7 Jul 2013 19:12:27 +0000 (12:12 -0700)
committerThomas Graf <tgraf@suug.ch>
Thu, 18 Jul 2013 21:10:19 +0000 (23:10 +0200)
(cherry picked from commit 968ccbe97d476e3a8485b04dbaf469e8d01b8811)
Signed-off-by: Thomas Graf <tgraf@suug.ch>
lib/utils.c

index 4457b1f26e01b5969fc7285de65e72110d5b9b9f..e491177d13bb2b6a2e1e7ece8317cbfa03012f6a 100644 (file)
@@ -328,6 +328,11 @@ char *nl_size2str(const size_t size, char *buf, const size_t len)
 {
        size_t i;
 
+       if (size == 0) {
+               snprintf(buf, len, "0B");
+               return buf;
+       }
+
        for (i = 0; i < ARRAY_SIZE(size_units); i++) {
                if (size >= size_units[i].limit) {
                        snprintf(buf, len, "%.2g%s",