chiark / gitweb /
security: rework selinux, smack, ima, apparmor detection logic
[elogind.git] / src / shared / utf8.c
index c3d97cc783f06e2805a4a2394a162e87a3b8b0e1..31120af046f1b091caf9253fa6dcae281ff3b369 100644 (file)
@@ -3,6 +3,7 @@
 /***
   This file is part of systemd.
 
+  Copyright 2008-2011 Kay Sievers
   Copyright 2012 Lennart Poettering
 
   systemd is free software; you can redistribute it and/or modify it
@@ -19,7 +20,7 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-/* This file is based on the GLIB utf8 validation functions. The
+/* Parts of this file are based on the GLIB utf8 validation functions. The
  * original license text follows. */
 
 /* gutf8.c - Operations on UTF-8 strings.
@@ -140,14 +141,15 @@ bool utf8_is_printable(const char* str, size_t length) {
 
         assert(str);
 
-        for (p = (const uint8_t*) str; length; p++) {
+        for (p = (const uint8_t*) str; length;) {
                 int encoded_len = utf8_encoded_valid_unichar((const char *)p);
-                int32_t val = utf8_encoded_to_unichar((const char*)p);
+                int val = utf8_encoded_to_unichar((const char*)p);
 
                 if (encoded_len < 0 || val < 0 || is_unicode_control(val))
                         return false;
 
                 length -= encoded_len;
+                p += encoded_len;
         }
 
         return true;