You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by dr...@apache.org on 2009/03/26 07:15:28 UTC

svn commit: r758529 - /incubator/thrift/trunk/tutorial/cpp/CppServer.cpp

Author: dreiss
Date: Thu Mar 26 06:15:26 2009
New Revision: 758529

URL: http://svn.apache.org/viewvc?rev=758529&view=rev
Log:
cpp: Eliminate a buffer overflow in the tutorial server

Negative numbers can have 11 characters :)

Modified:
    incubator/thrift/trunk/tutorial/cpp/CppServer.cpp

Modified: incubator/thrift/trunk/tutorial/cpp/CppServer.cpp
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/tutorial/cpp/CppServer.cpp?rev=758529&r1=758528&r2=758529&view=diff
==============================================================================
--- incubator/thrift/trunk/tutorial/cpp/CppServer.cpp (original)
+++ incubator/thrift/trunk/tutorial/cpp/CppServer.cpp Thu Mar 26 06:15:26 2009
@@ -69,8 +69,8 @@
 
     SharedStruct ss;
     ss.key = logid;
-    char buffer[11];
-    sprintf(buffer, "%d", val);
+    char buffer[12];
+    snprintf(buffer, sizeof(buffer), "%d", val);
     ss.value = buffer;
 
     log[logid] = ss;