Re: [PATCH] lib: vsprintf: fix invalid arg check

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Rientjes
Date: Thursday, November 11, 2010 - 1:38 pm

On Thu, 11 Nov 2010, Vasiliy Kulikov wrote:


All sizes passed to vsprintf() greater than INT_MAX are invalid; that's 
what the original code is testing, warning, and handling correctly.


Andrew was commenting that this was the only additional information you 
provided instead of showing a working example.


That's buggy because len may be greater than sizeof(buf).  snprintf() 
returns the number of characters that would have been generated if it 
wasn't truncated so that we can test that value upon return.


Right, that's the behavior of snprintf(), but that doesn't mean the passed 
size can be anything larger than INT_MAX.


No, it shouldn't, these functions return int.  INT_MAX is the largest 
value we can handle successfully and that's why it is the special case for 
sprintf() and vsprintf().

The code as it stands is correct not because of the type of the size but 
rather the type of the return value.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] lib: vsprintf: fix invalid arg check, Vasiliy Kulikov, (Wed Nov 10, 1:38 pm)
Re: [PATCH] lib: vsprintf: fix invalid arg check, Andrew Morton, (Wed Nov 10, 2:08 pm)
Re: [PATCH] lib: vsprintf: fix invalid arg check, David Rientjes, (Wed Nov 10, 2:38 pm)
Re: [PATCH] lib: vsprintf: fix invalid arg check, Vasiliy Kulikov, (Thu Nov 11, 1:34 am)
Re: [PATCH] lib: vsprintf: fix invalid arg check, David Rientjes, (Thu Nov 11, 1:38 pm)
Re: [PATCH] lib: vsprintf: fix invalid arg check, Vasiliy Kulikov, (Thu Nov 11, 2:02 pm)
Re: [PATCH] lib: vsprintf: fix invalid arg check, David Rientjes, (Thu Nov 11, 2:34 pm)
Re: [PATCH] lib: vsprintf: fix invalid arg check, Vasiliy Kulikov, (Fri Nov 12, 10:42 am)