Dear Holger

On 02.03.2014 08:06, Holger Hans Peter Freyther wrote:

> 
>> +                    nchars = snprintf(buf + buf_offs, sizeof(buf) - 
>> buf_offs,
>> +                                      "%s[L%d]> ",
>> +                                      osmo_hexdump(start, lxhs[i] - start),
>> +                                      i+1);
> 
>> +    nchars = snprintf(buf + buf_offs, sizeof(buf) - buf_offs,
>> +                      "%s", osmo_hexdump(start, msg->tail - start));
>> +    nchars = snprintf(buf, sizeof(buf) - buf_offs,
>> +                      "!!! L%d out of range", i+1);
> 
> So sizeof(buf) - buf_offs can only be 0 when the output is already null
> terminated?

No, the expressions can never be 0 due to
  if (nchars < 0 || nchars + buf_offs >= sizeof(buf)) return "ERROR";

But even if it could, the string has already been \0 terminated by prior
calls to snprintf (the initial size value is always > 0).

Jacob




> 
> kind regards
>       holger
> 


Reply via email to