Re: How Do I Get snprintf(3) to Return -1?

2006-01-06 Thread Siju George
On 1/6/06, Han Boetes <[EMAIL PROTECTED]> wrote: > Theo de Raadt wrote: > > On some other systems, yes. On OpenBSD -- today -- it cannot return -1. > > > > However, that is absolutely no excuse to go writing unportable code. > > > > You must check for either ret > buflen or ret == -1 being a failu

Re: How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread Han Boetes
Theo de Raadt wrote: > On some other systems, yes. On OpenBSD -- today -- it cannot return -1. > > However, that is absolutely no excuse to go writing unportable code. > > You must check for either ret > buflen or ret == -1 being a failure > condition. Wrong! Will you ever learn to code something

Re: How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread Moritz Grimm
Theo de Raadt wrote: I'm having trouble making snprintf return -1. I've tried stuff like: len = snprintf(str, 0, "%.-Z\n", 9); printf("%d", len); but that just prints `2'. Does snprintf ever return -1? The "new" snprintf() returns -1 on ``output or encoding error'', as was

Re: How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread veins
Otto Moerbeek wrote: On Thu, 5 Jan 2006, veins wrote: I'm having trouble making snprintf return -1. I've tried stuff like: len = snprintf(str, 0, "%.-Z\n", 9); printf("%d", len); but that just prints `2'. Does snprintf ever return -1? -Ray- you might want to ta

Re: How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread Todd C. Miller
In message <[EMAIL PROTECTED]> so spake Ray Lai (ray): > I'm having trouble making snprintf return -1. I've tried stuff like: > > len = snprintf(str, 0, "%.-Z\n", 9); > printf("%d", len); > > but that just prints `2'. Does snprintf ever return -1? Not on OpenBSD. It can o

Re: How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread Otto Moerbeek
On Thu, 5 Jan 2006, veins wrote: > > I'm having trouble making snprintf return -1. I've tried stuff like: > > > > len = snprintf(str, 0, "%.-Z\n", 9); > > printf("%d", len); > > > > but that just prints `2'. Does snprintf ever return -1? > > > > -Ray- > > > you might want to take a

Re: How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread veins
I'm having trouble making snprintf return -1. I've tried stuff like: len = snprintf(str, 0, "%.-Z\n", 9); printf("%d", len); but that just prints `2'. Does snprintf ever return -1? -Ray- you might want to take a look at how vfprintf() is implemented in /usr/src/lib/libc

Re: How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread Theo de Raadt
> According to printf(3): > > snprintf() and vsnprintf() will write at most size-1 of the characters > printed into the output string (the size'th character then gets the ter- > minating `\0'); if the return value is greater than or equal to the size > argument, the string

How Do I Get snprintf(3) to Return -1?

2006-01-05 Thread Ray Lai
According to printf(3): snprintf() and vsnprintf() will write at most size-1 of the characters printed into the output string (the size'th character then gets the ter- minating `\0'); if the return value is greater than or equal to the size argument, the string was