Permalink
Browse files

Add infoSize parameter to get_sdk_info

Add infoSize parameter to get_sdk_info function to replace sprintf call
by a snprintf call.
  • Loading branch information...
1 parent d3d17da commit e13ffe3bf84f7238b57bde73a4780cbf70bcc511 @ffontaine ffontaine committed Mar 18, 2012
Showing with 15 additions and 5 deletions.
  1. +7 −0 ChangeLog
  2. +5 −4 upnp/src/genlib/net/http/httpreadwrite.c
  3. +3 −1 upnp/src/inc/httpreadwrite.h
View
@@ -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
@@ -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
@@ -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,14 +559,15 @@ 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
*
* 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" */

0 comments on commit e13ffe3

Please sign in to comment.