Treat large argument as error in UpnpAddVirtualDir.

This commit is contained in:
Yoichi NAKAYAMA 2012-03-11 01:40:48 +09:00
parent a0dc3482dc
commit e4678168fa
2 changed files with 5 additions and 0 deletions

View File

@ -6,6 +6,7 @@ Version 1.6.16
Further measures against buffer overflows.
Treat large argument as error in UpnpAddVirtualDir.
Do not clear buffer before snprintf.
2012-03-10 Yoichi NAKAYAMA <yoichi.nakayama(at)gmail.com>

View File

@ -3877,9 +3877,13 @@ int UpnpAddVirtualDir(const char *newDirName)
}
if( *newDirName != '/' ) {
if (strlen(newDirName) > sizeof(dirName) - 2)
return UPNP_E_INVALID_PARAM;
dirName[0] = '/';
strncpy( dirName + 1, newDirName, sizeof( dirName ) - 2 );
} else {
if (strlen(newDirName) > sizeof(dirName) - 1)
return UPNP_E_INVALID_PARAM;
strncpy( dirName, newDirName, sizeof( dirName ) - 1 );
}