Fix util_is_printable_string

The method used did not account for multi-part strings.

Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Pantelis Antoniou 2013-01-04 21:12:58 +02:00 committed by Jon Loeliger
parent 94a4799b20
commit 1c1efd6954

12
util.c
View file

@ -72,7 +72,7 @@ char *join_path(const char *path, const char *name)
int util_is_printable_string(const void *data, int len)
{
const char *s = data;
const char *ss;
const char *ss, *se;
/* zero length is not */
if (len == 0)
@ -82,14 +82,20 @@ int util_is_printable_string(const void *data, int len)
if (s[len - 1] != '\0')
return 0;
se = s + len;
while (s < se) {
ss = s;
while (*s && isprint(*s))
while (s < se && *s && isprint(*s))
s++;
/* not zero, or not done yet */
if (*s != '\0' || (s + 1 - ss) < len)
if (*s != '\0' || s == ss)
return 0;
s++;
}
return 1;
}