Add infoSize parameter to get_sdk_info

Add infoSize parameter to get_sdk_info function to replace sprintf call
by a snprintf call.
This commit is contained in:
Fabrice Fontaine 2012-03-18 15:23:59 +01:00
parent d3d17da6e5
commit e13ffe3bf8
3 changed files with 15 additions and 5 deletions

View File

@ -2,6 +2,13 @@
Version 1.6.16
*******************************************************************************
2012-03-18 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
Add infoSize parameter to get_sdk_info
Add infoSize parameter to get_sdk_info function to replace sprintf call
by a snprintf call.
2012-03-16 Fabrice Fontaine <fabrice.fontaine(at)orange.com>
Check return code in ixml

View File

@ -1746,7 +1746,7 @@ int http_MakeMessage(membuffer *buf, int http_major_version,
} else if (c == 'S' || c == 'U') {
/* SERVER or USER-AGENT header */
temp_str = (c == 'S') ? "SERVER: " : "USER-AGENT: ";
get_sdk_info(tempbuf);
get_sdk_info(tempbuf, sizeof(tempbuf));
if (http_MakeMessage(buf, http_major_version, http_minor_version,
"ss", temp_str, tempbuf) != 0)
goto error_handler;
@ -2107,6 +2107,7 @@ int http_OpenHttpGetEx(
*
* Parameters:
* OUT char *info; buffer to store the operating system information
* IN size_t infoSize; size of buffer
*
* Description:
* Returns the server information for the operating system
@ -2115,14 +2116,14 @@ int http_OpenHttpGetEx(
* UPNP_INLINE void
************************************************************************/
/* 'info' should have a size of at least 100 bytes */
void get_sdk_info(OUT char *info)
void get_sdk_info(OUT char *info, IN size_t infoSize)
{
#ifdef WIN32
OSVERSIONINFO versioninfo;
versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (GetVersionEx(&versioninfo) != 0)
sprintf(info,
snprintf(info, infoSize,
"%d.%d.%d %d/%s, UPnP/1.0, Portable SDK for UPnP devices/"
PACKAGE_VERSION "\r\n", versioninfo.dwMajorVersion,
versioninfo.dwMinorVersion, versioninfo.dwBuildNumber,
@ -2136,7 +2137,7 @@ void get_sdk_info(OUT char *info)
ret_code = uname(&sys_info);
if (ret_code == -1)
*info = '\0';
sprintf(info,
snprintf(info, infoSize,
"%s/%s, UPnP/1.0, Portable SDK for UPnP devices/"
PACKAGE_VERSION "\r\n", sys_info.sysname, sys_info.release);
#endif

View File

@ -2,6 +2,7 @@
*
* Copyright (c) 2000-2003 Intel Corporation
* All rights reserved.
* Copyright (c) 2012 France Telecom All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -558,6 +559,7 @@ int http_OpenHttpGetEx(IN const char *url_str,
*
* Parameters:
* OUT char *info; buffer to store the operating system information
* IN size_t infoSize; size of buffer
*
* Description:
* Returns the server information for the operating system
@ -565,7 +567,7 @@ int http_OpenHttpGetEx(IN const char *url_str,
* Return:
* UPNP_INLINE void
************************************************************************/
void get_sdk_info( OUT char *info );
void get_sdk_info( OUT char *info, IN size_t infoSize );
#ifdef __cplusplus
} /* #extern "C" */