diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-06-11 17:02:52 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-06-11 17:02:52 +0000 |
commit | 6cc3bdcf308ac3dea6df8dfe8cc3675f6ad60e88 (patch) | |
tree | 134a6420e75caed1257de3ba00a7aca250d42369 /pjlib/src/pj/compat | |
parent | 0097c64fa8671c0c9e718df6052987f7d83dbf6a (diff) |
Ticket #333: Added buffer overflow detection in vsprintf emulation for Symbian
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1361 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src/pj/compat')
-rw-r--r-- | pjlib/src/pj/compat/string_compat.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/pjlib/src/pj/compat/string_compat.c b/pjlib/src/pj/compat/string_compat.c index 28f13123..d87bb967 100644 --- a/pjlib/src/pj/compat/string_compat.c +++ b/pjlib/src/pj/compat/string_compat.c @@ -19,6 +19,8 @@ #include <pj/types.h> #include <pj/compat/string.h> #include <pj/ctype.h> +#include <pj/assert.h> + #if defined(PJ_HAS_STRING_H) && PJ_HAS_STRING_H != 0 /* Nothing to do */ @@ -64,8 +66,16 @@ PJ_DEF(int) snprintf(char *s1, pj_size_t len, const char *s2, ...) PJ_DEF(int) vsnprintf(char *s1, pj_size_t len, const char *s2, va_list arg) { - PJ_UNUSED_ARG(len); - return vsprintf(s1,s2,arg); +#define MARK_CHAR ((char)255) + int rc; + + s1[len-1] = MARK_CHAR; + + rc = vsprintf(s1,s2,arg); + + pj_assert(s1[len-1] == MARK_CHAR || s1[len-1] == '\0'); + + return rc; } #endif |