Skip to content

Commit

Permalink
cpp: Eliminate a buffer overflow in the tutorial server
Browse files Browse the repository at this point in the history
Negative numbers can have 11 characters :)


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@758529 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dreiss committed Mar 26, 2009
1 parent cedf71b commit b87a4d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tutorial/cpp/CppServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class CalculatorHandler : public CalculatorIf {

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;
Expand Down

0 comments on commit b87a4d4

Please sign in to comment.