X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=sdump.c;h=3748672ade3fcbe715c29f4ecab29f2b4c6a24d0;hb=53293ee30678d3db753e51820cc554c0b2b1bd97;hp=5782f134b67eaa7d9a5be553616ab6d3efb602af;hpb=c8f608f4c4c6d2eb6cb7b12cb60de04cadcb3750;p=~andy%2Ffetchmail diff --git a/sdump.c b/sdump.c index 5782f134..3748672a 100644 --- a/sdump.c +++ b/sdump.c @@ -1,7 +1,12 @@ -/* sdump.c -- library to allocate a printable version of a string */ +/* sdump.c -- library to allocate and format a printable version of a + * string with embedded NUL */ + /** \file sdump.c * \author Matthias Andree * \date 2009 + * + * This file is available under the GNU Lesser General Public License + * v2.1 or any later version of the GNU LGPL. */ #include /* for isprint() */ @@ -14,7 +19,9 @@ /** sdump converts a byte string \a in of size \a len into a printable * string and returns a pointer to the memory region. * \returns a pointer to a xmalloc()ed string that the caller must - * free() after use. This function causes program abort on failure. */ + * free() after use. This function causes program abort on failure + * through xmalloc. xmalloc is a function that calls malloc() and aborts + * the program if malloc() returned NULL i. e. failure. */ char *sdump(const char *in, size_t len) { size_t outlen = 0, i; @@ -29,7 +36,7 @@ char *sdump(const char *in, size_t len) if (isprint((unsigned char)in[i])) { *(oi++) = in[i]; } else { - oi += sprintf(oi, "\\x%02X", in[i]); + oi += sprintf(oi, "\\x%02X", (unsigned char)in[i]); } } *oi = '\0';