]> sourceware.org Git - lvm2.git/commitdiff
libdaemon: prohibit use of %d for 64bit numbres
authorZdenek Kabelac <zkabelac@redhat.com>
Mon, 9 Nov 2015 13:03:25 +0000 (14:03 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 9 Nov 2015 13:03:25 +0000 (14:03 +0100)
Do not let pass %d and print internal error when found one.
Require all users to use  FMTd64 - it's seriously confusing.

libdaemon/client/config-util.c

index ec5ea98d6272018fe1445eb09d27f3842e3d4894..bbf4218f328ca4bdddfad40ffcf43c97b128dc6a 100644 (file)
@@ -38,7 +38,12 @@ int buffer_append_vf(struct buffer *buf, va_list ap)
                        goto fail;
                }
                keylen = strchr(next, '=') - next;
-               if (strstr(next, "%d") || strstr(next, FMTd64)) {
+               if (strstr(next, "%d")) {
+                        /* Use of plain %d is prohibited, use  FMTd64 */
+                       log_error(INTERNAL_ERROR "Do not use  %%d and use correct 64bit form");
+                       goto fail;
+               }
+               if (strstr(next, FMTd64)) {
                        value = va_arg(ap, int64_t);
                        if (dm_asprintf(&append, "%.*s= %" PRId64 "\n", keylen, next, value) < 0)
                                goto fail;
This page took 0.039292 seconds and 5 git commands to generate.