bug-gnulib
[Top][All Lists]
Advanced

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

Re: [Bug-gnulib] vasnprintf.c: patch for inadequate snprintf on HPUX 10.


From: Jim Meyering
Subject: Re: [Bug-gnulib] vasnprintf.c: patch for inadequate snprintf on HPUX 10.20
Date: Mon, 20 Oct 2003 13:25:43 +0200

Hi Bruno,

> Thanks for the analysis and patch; I've committed the following slightly
> modified patch (which also copes with the possibility that allocated==0).

Did you mean to remove the part of my patch that would make
vasnprintf fail when doubling the amount of space would
result in overflow?  Now, on a *very* long line, and on a system
with lots of memory, it can infloop.
Admittedly, this use of `ENSURE_ALLOCATION' is now consistent
with all of the others in *not* checking for overflow.

> *** vasnprintf.c      13 Sep 2003 22:14:47 -0000      1.7
> --- vasnprintf.c      20 Oct 2003 10:51:01 -0000
> ***************
> *** 707,713 ****
>                           p[1] = '\0';
>                           continue;
>                         }
> !                     count = retcount;
>                     }
>   #endif
>   
> --- 707,729 ----
>                           p[1] = '\0';
>                           continue;
>                         }
> !                     else
> !                       {
> !                         /* Look at the snprintf() return value.  */
> !                         if (retcount < 0)
> !                           {
> !                             /* HP-UX 10.20 snprintf() is doubly deficient:
> !                                It doesn't understand the '%n' directive,
> !                                *and* it returns -1 (rather than the length
> !                                that would have been required) when the
> !                                buffer is too small.  */
> !                             size_t bigger_need = 2 * allocated + 12;
> !                             ENSURE_ALLOCATION (bigger_need);
> !                             continue;
> !                           }
> !                         else
> !                           count = retcount;
> !                       }
>                     }
>   #endif
>   




reply via email to

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