[Crosstoolchain-logs] [device-tree-compiler] 67/198: Fix util_is_printable_string

Hector Oron zumbi at moszumanska.debian.org
Thu Dec 8 17:06:54 UTC 2016


This is an automated email from the git hooks/post-receive script.

zumbi pushed a commit to branch upstream/1.4.x
in repository device-tree-compiler.

commit 1c1efd69545a101d7181fc8e5df2b9a3545a58e8
Author: Pantelis Antoniou <panto at antoniou-consulting.com>
Date:   Fri Jan 4 21:12:58 2013 +0200

    Fix util_is_printable_string
    
    The method used did not account for multi-part strings.
    
    Signed-off-by: Pantelis Antoniou <panto at antoniou-consulting.com>
    Acked-by: David Gibson <david at gibson.dropbear.id.au>
---
 util.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/util.c b/util.c
index 2422c34..45f186b 100644
--- a/util.c
+++ b/util.c
@@ -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,13 +82,19 @@ int util_is_printable_string(const void *data, int len)
 	if (s[len - 1] != '\0')
 		return 0;
 
-	ss = s;
-	while (*s && isprint(*s))
-		s++;
+	se = s + len;
 
-	/* not zero, or not done yet */
-	if (*s != '\0' || (s + 1 - ss) < len)
-		return 0;
+	while (s < se) {
+		ss = s;
+		while (s < se && *s && isprint(*s))
+			s++;
+
+		/* not zero, or not done yet */
+		if (*s != '\0' || s == ss)
+			return 0;
+
+		s++;
+	}
 
 	return 1;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list