From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Thibault Subject: [PATCH][Mini-OS] printf("%n" behavior on overflow Date: Fri, 28 Dec 2007 12:08:57 +0000 Message-ID: <20071228120857.GE4863@implementation.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org Hello, In C99 (7.19.6.2.10), the behavior of scanf("stuff... %n", ..., &n) is said to be undefined if the value to be put is n can't fit. I guess we can safely consider that the same applies to printf. Signed-off-by: Samuel Thibault diff -r 5da126f8960e -r 077f5106d691 extras/mini-os/lib/printf.c --- a/extras/mini-os/lib/printf.c Fri Dec 28 11:52:16 2007 +0000 +++ b/extras/mini-os/lib/printf.c Fri Dec 28 12:01:05 2007 +0000 @@ -426,8 +426,6 @@ int vsnprintf(char *buf, size_t size, co case 'n': - /* FIXME: - * What does C99 say about the overflow case here? */ if (qualifier == 'l') { long * ip = va_arg(args, long *); *ip = (str - buf);