Ignore:
Timestamp:
Jan 6, 2010 2:35:13 PM (14 years ago)
Author:
bennylp
Message:

Ticket #1012: Potential buffer overflow in Unicode string conversion (thanks Orville Pike for the report)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/unicode_win32.c

    r2394 r3047  
    3131    len = MultiByteToWideChar(CP_ACP, 0, s, len,  
    3232                              buf, buf_count); 
    33     buf[len] = 0; 
     33    if (buf_count) { 
     34        if (len < buf_count) 
     35            buf[len] = 0; 
     36        else 
     37            buf[len-1] = 0; 
     38    } 
     39 
    3440    return buf; 
    3541} 
     
    4248 
    4349    len = WideCharToMultiByte(CP_ACP, 0, wstr, len, buf, buf_size, NULL, NULL); 
    44     buf[len] = '\0'; 
     50    if (buf_size) { 
     51        if (len < buf_size) 
     52            buf[len] = '\0'; 
     53        else 
     54            buf[len-1] = '\0'; 
     55    } 
     56 
    4557    return buf; 
    4658} 
Note: See TracChangeset for help on using the changeset viewer.