Ignore:
Timestamp:
Oct 8, 2013 9:08:13 AM (11 years ago)
Author:
bennylp
Message:

Re #1703: fixing general bugs. First installment: correct handling of snprintf return value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjnath/src/pjnath/errno.c

    r3553 r4613  
    134134                                   "Unknown pjnath error %d", 
    135135                                   statcode); 
    136     if (errstr.slen < 0) errstr.slen = 0; 
    137     else if (errstr.slen > (int)bufsize) errstr.slen = bufsize; 
     136    if (errstr.slen < 1 || errstr.slen >= (int)bufsize) 
     137        errstr.slen = bufsize-1; 
    138138 
    139139    return errstr; 
     
    165165    } 
    166166 
    167     if (errstr.slen < 0) errstr.slen = 0; 
    168     else if (errstr.slen > (int)bufsize) errstr.slen = bufsize; 
     167    if (errstr.slen < 1 || errstr.slen >= (int)bufsize) 
     168        errstr.slen = bufsize-1; 
    169169 
    170170    return errstr; 
Note: See TracChangeset for help on using the changeset viewer.