qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [Qemu-trivial] [PATCH v7] block/vvfat: assert return va


From: Michael Tokarev
Subject: Re: [Qemu-devel] [Qemu-trivial] [PATCH v7] block/vvfat: assert return value of fopen which may fail
Date: Mon, 18 Aug 2014 15:42:22 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.7.0

18.08.2014 12:06, Peter Maydell wrote:
> On 18 August 2014 09:00, zhanghailiang <address@hidden> wrote:
>> From: Li Liu <address@hidden>
>>
>> fopen() may return NULL which will cause setbuf() segmentfault
>>
>> Signed-off-by: zhanghailiang <address@hidden>
>> Signed-off-by: Li Liu <address@hidden>
>> ---
>>  block/vvfat.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/block/vvfat.c b/block/vvfat.c
>> index 70176b1..62023e1 100644
>> --- a/block/vvfat.c
>> +++ b/block/vvfat.c
>> @@ -1084,6 +1084,7 @@ static int vvfat_open(BlockDriverState *bs, QDict 
>> *options, int flags,
>>
>>  DLOG(if (stderr == NULL) {
>>      stderr = fopen("vvfat.log", "a");
>> +    assert(stderr);
>>      setbuf(stderr, NULL);
>>  })
> 
> An assertion is no better than a segfault.
> 
> Better I think would be to just remove this whole lump of code
> entirely. Lots of other files do debug printing to stderr without
> attempting to open a file if stderr happens to be NULL, why
> should vvfat.c be special?

Indeed.  I've applied a patch which just removes these 6 lines of code
(and sent it to the list too, for review).

Thanks,

/mjt



reply via email to

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