1 message in com.xensource.lists.xen-devel[Xen-devel] [PATCH][Mini-OS] printf("...
FromSent OnAttachments
Samuel Thibault28 Dec 2007 04:08 
Subject:[Xen-devel] [PATCH][Mini-OS] printf("%n" behavior on overflow
From:Samuel Thibault (samu@eu.citrix.com)
Date:12/28/2007 04:08:34 AM
List:com.xensource.lists.xen-devel

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 <samu@citrix.com>

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);