Fixed ticket #106: writing data outside buffer in Win32 error string generation

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@954 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Benny Prijono 2007-02-16 23:56:37 +00:00
parent 83217fa9ed
commit 2e5516e6c3
1 changed files with 3 additions and 0 deletions

View File

@ -194,6 +194,7 @@ int platform_strerror( pj_os_err_type os_errcode,
buf,
bufsize,
NULL);
buf[bufsize-1] = '\0';
#endif
if (len) {
@ -208,6 +209,8 @@ int platform_strerror( pj_os_err_type os_errcode,
if (!len) {
len = pj_ansi_snprintf( buf, bufsize, "Win32 error code %u",
(unsigned)os_errcode);
if (len < 0 || len >= (int)bufsize)
len = bufsize-1;
buf[len] = '\0';
}