Changeset 1361


Ignore:
Timestamp:
Jun 11, 2007 5:02:52 PM (12 years ago)
Author:
bennylp
Message:

Ticket #333: Added buffer overflow detection in vsprintf emulation for Symbian

File:
1 edited

Legend:

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

    r1235 r1361  
    2020#include <pj/compat/string.h> 
    2121#include <pj/ctype.h> 
     22#include <pj/assert.h> 
     23 
    2224 
    2325#if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0 
     
    6567PJ_DEF(int) vsnprintf(char *s1, pj_size_t len, const char *s2, va_list arg) 
    6668{ 
    67     PJ_UNUSED_ARG(len); 
    68     return vsprintf(s1,s2,arg); 
     69#define MARK_CHAR   ((char)255) 
     70    int rc; 
     71 
     72    s1[len-1] = MARK_CHAR; 
     73 
     74    rc = vsprintf(s1,s2,arg); 
     75 
     76    pj_assert(s1[len-1] == MARK_CHAR || s1[len-1] == '\0'); 
     77 
     78    return rc; 
    6979} 
    7080 
Note: See TracChangeset for help on using the changeset viewer.