From e13ffe3bf84f7238b57bde73a4780cbf70bcc511 Mon Sep 17 00:00:00 2001 From: Fabrice Fontaine Date: Sun, 18 Mar 2012 15:23:59 +0100 Subject: [PATCH] Add infoSize parameter to get_sdk_info Add infoSize parameter to get_sdk_info function to replace sprintf call by a snprintf call. --- ChangeLog | 7 +++++++ upnp/src/genlib/net/http/httpreadwrite.c | 9 +++++---- upnp/src/inc/httpreadwrite.h | 4 +++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2619d8..6945df6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ Version 1.6.16 ******************************************************************************* +2012-03-18 Fabrice Fontaine + + 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 Check return code in ixml diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c index 4e0d65b..049ea6b 100644 --- a/upnp/src/genlib/net/http/httpreadwrite.c +++ b/upnp/src/genlib/net/http/httpreadwrite.c @@ -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 diff --git a/upnp/src/inc/httpreadwrite.h b/upnp/src/inc/httpreadwrite.h index f48ead8..18ee957 100644 --- a/upnp/src/inc/httpreadwrite.h +++ b/upnp/src/inc/httpreadwrite.h @@ -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" */