]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
hexdump: use xasprintf in conv_c()
authorOndrej Oprala <ooprala@redhat.com>
Mon, 23 Sep 2013 13:39:27 +0000 (15:39 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 8 Nov 2013 11:54:53 +0000 (12:54 +0100)
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
text-utils/conv.c

index 4f7a248f297dba4c2c8f449093cd72eae30d8780..abb62d06de2e49c44d4ad27d35ded3685a748862 100644 (file)
 #include <ctype.h>
 #include <sys/types.h>
 #include "hexdump.h"
+#include "xalloc.h"
 
 void
 conv_c(PR *pr, u_char *p)
 {
-       char buf[10];
+       char *buf = NULL;
        char const *str;
 
        switch(*p) {
@@ -75,11 +76,12 @@ conv_c(PR *pr, u_char *p)
                *pr->cchar = 'c';
                printf(pr->fmt, *p);
        } else {
-               sprintf(buf, "%03o", (int)*p);
+               xasprintf(&buf, "%03o", (int)*p);
                str = buf;
 strpr:         *pr->cchar = 's';
                printf(pr->fmt, str);
        }
+       free(buf);
 }
 
 void