commit | f33c7c670b189fbb58eb9cb868703ca99a107b7c | [log] [tgz] |
---|---|---|
author | David Reiss <dreiss@apache.org> | Thu Mar 26 06:15:26 2009 +0000 |
committer | David Reiss <dreiss@apache.org> | Thu Mar 26 06:15:26 2009 +0000 |
tree | a64b9d30c5339220bc36084f1f68ea07635215ab | |
parent | 755c8156e816a9c93b635d7a997fb1954aee45c5 [diff] |
cpp: Eliminate a buffer overflow in the tutorial server Negative numbers can have 11 characters :) git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758529 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp index a2c30d2..044e1d9 100644 --- a/tutorial/cpp/CppServer.cpp +++ b/tutorial/cpp/CppServer.cpp
@@ -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;