chiark / gitweb /
sd-bus: sync kdbus.h (ABI break)
[elogind.git] / src / libsystemd / sd-id128 / sd-id128.c
index a1e44e6d19df927b6fa371aa968483aa44b60176..c876f6e381f90d1f48962cc366a909c5348d2c0c 100644 (file)
@@ -183,11 +183,14 @@ _public_ int sd_id128_get_boot(sd_id128_t *ret) {
         for (j = 0, p = buf; j < 16; j++) {
                 int a, b;
 
-                if (p >= buf + k)
+                if (p >= buf + k - 1)
                         return -EIO;
 
-                if (*p == '-')
+                if (*p == '-') {
                         p++;
+                        if (p >= buf + k - 1)
+                                return -EIO;
+                }
 
                 a = unhexchar(p[0]);
                 b = unhexchar(p[1]);
@@ -219,7 +222,7 @@ _public_ int sd_id128_randomize(sd_id128_t *ret) {
 
         /* Turn this into a valid v4 UUID, to be nice. Note that we
          * only guarantee this for newly generated UUIDs, not for
-         * pre-existing ones.*/
+         * pre-existing ones. */
 
         *ret = make_v4_uuid(t);
         return 0;