qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 139/147] meson: replace create-config with meson configure_fi


From: Paolo Bonzini
Subject: Re: [PATCH 139/147] meson: replace create-config with meson configure_file
Date: Tue, 11 Aug 2020 19:25:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

On 11/08/20 18:25, Philippe Mathieu-Daudé wrote:
> Alexander reported [*] a problem when ARRAY_SIZE(whitelist_rw) == 0 you
> access an undefined address:

But that's not accessing an undefined address, it's taking the address past
the last item---which should be okay.  And I cannot reproduce it with:

        #include <stdio.h>
        const char *x[] = {};
        int main()
        {
                printf("%p %p\n", x, &x[0]);
        }

and -fsanitize=undefined, using either GCC 10 or clang 10 (it breaks horribly
with &x[1] so the testcase makes sense).

This should fix it, it should also be unnecessary but I guess I'm not going
to nitpick:

diff --git a/block.c b/block.c
index 67ca5433d5..2ba76b2c36 100644
--- a/block.c
+++ b/block.c
@@ -433,9 +433,11 @@ static int bdrv_format_is_whitelisted(const char 
*format_name, bool read_only)
 {
     static const char *whitelist_rw[] = {
         CONFIG_BDRV_RW_WHITELIST
+        NULL
     };
     static const char *whitelist_ro[] = {
         CONFIG_BDRV_RO_WHITELIST
+        NULL
     };
     const char **p;
 
@@ -443,13 +445,13 @@ static int bdrv_format_is_whitelisted(const char 
*format_name, bool read_only)
         return 1;               /* no whitelist, anything goes */
     }
 
-    for (p = whitelist_rw; p < &whitelist_rw[ARRAY_SIZE(whitelist_rw)]; p++) {
+    for (p = whitelist_rw; *p; p++) {
         if (!strcmp(format_name, *p)) {
             return 1;
         }
     }
     if (read_only) {
-        for (p = whitelist_ro; p < &whitelist_ro[ARRAY_SIZE(whitelist_ro)]; 
p++) {
+        for (p = whitelist_ro; *p; p++) {
             if (!strcmp(format_name, *p)) {
                 return 1;
             }

> The question is why CONFIG_BDRV_RW_WHITELIST & CONFIG_BDRV_RO_WHITELIST
> aren't generated by meson.build...

What do you mean?  If you mean why they are in config-host.mak, it's because I 
have
only done a very minimal conversion from config-host.mak to Meson options.

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]