avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] Re: [bug #22800] sprintf() expands a 128char string param


From: Dmitry K.
Subject: [avr-libc-dev] Re: [bug #22800] sprintf() expands a 128char string parameter incorrectly
Date: Wed, 2 Apr 2008 08:55:03 +1100
User-agent: KMail/1.5

On Wednesday 02 April 2008 07:37, Joerg Wunsch wrote:
> Update of bug #22800 (project avr-libc):
>
>              Assigned to:                    None => dmix
>
>     _______________________________________________________
>
> Follow-up Comment #1:
>
> Dmitry, can you check this, please?
>
> I think this is a bug somewhere in the following snippet:
>
>             case 's':
>               pnt = va_arg (ap, char *);
>               size = strnlen (pnt, (flags & FL_PREC) ? prec : ~0);
>             no_pgmstring:
>               flags &= ~FL_PGMSTRING;
>               goto str_lpad;
>
>             case 'S':
>               pnt = va_arg (ap, char *);
>               size = strnlen_P (pnt, (flags & FL_PREC) ? prec : ~0);
>               flags |= FL_PGMSTRING;
>
>             str_lpad:
>               if (!(flags & FL_LPAD)) {
>                   while (size < width) {
>                       putc (' ', stream);
>                       width--;
>                   }
>               }
>               while (size) {
>                   putc (GETBYTE (flags, FL_PGMSTRING, pnt), stream);
>                   if (width) width -= 1;
>                   size -= 1;
>               }
>
> My guess is that width has to be declared as uint16_t rather
> than unsigned char.  What do you think?

I will look this at the nearest time.

About width: the avr-libc-1.4 printf() has the documented
limit for width (and precision): 127.  The avr-libc-1.6
printf has this limit (also documented): 255.

Dmitry.





reply via email to

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