X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Futils.c;h=2cc0e9110f9383105e9b9c85333a269c1cb20d44;hb=c10c3c7cb3e779af5286430d5c9bb835a873ab32;hp=12ae21aec54214dde3cd013eaf54956e36e0ebd9;hpb=d8e8d7a74b791743ad67e8bdba10508b0f901beb;p=ppp.git diff --git a/pppd/utils.c b/pppd/utils.c index 12ae21a..2cc0e91 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -300,9 +300,10 @@ vslprintf(buf, buflen, fmt, args) if (fillch == '0' && prec >= 0) { n = prec; } else { - n = strlen((char *)p); - if (prec >= 0 && n > prec) - n = prec; + if (prec == -1) + n = strlen((char *)p); + else + n = strnlen((char *)p, prec); } while (n > 0 && buflen > 0) { c = *p++; @@ -385,9 +386,10 @@ vslprintf(buf, buflen, fmt, args) } len = num + sizeof(num) - 1 - str; } else { - len = strlen(str); - if (prec >= 0 && len > prec) - len = prec; + if (prec == -1) + len = strlen(str); + else + len = strnlen(str, prec); } if (width > 0) { if (width > buflen)