qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] tests/hd-geo-test: Don't pass NULL to unlink()


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] tests/hd-geo-test: Don't pass NULL to unlink()
Date: Fri, 5 Aug 2016 12:57:11 +0100

On 5 August 2016 at 12:19, Markus Armbruster <address@hidden> wrote:
> Peter Maydell <address@hidden> writes:
>
>> The unlink() function doesn't accept a NULL pointer, so
>> don't pass it one. Spotted by the clang sanitizer.
>>
>> Signed-off-by: Peter Maydell <address@hidden>
>> ---
>>  tests/hd-geo-test.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c
>> index 12ee392..6176e81 100644
>> --- a/tests/hd-geo-test.c
>> +++ b/tests/hd-geo-test.c
>> @@ -416,7 +416,9 @@ int main(int argc, char **argv)
>>      ret = g_test_run();
>>
>>      for (i = 0; i < backend_last; i++) {
>> -        unlink(img_file_name[i]);
>> +        if (img_file_name[i]) {
>> +            unlink(img_file_name[i]);
>> +        }
>>      }
>>
>>      return ret;
>
> And what terrible, terrible things unlink()'s going to do when passed a
> null pointer?  Turns out the same scary terrible thing it has always
> done: return -1 and set errno = EFAULT.

Feel free to send a bug report to the glibc folks saying
they shouldn't have marked it as __nonnull((1)).

thanks
-- PMM



reply via email to

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