Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Fix buffer overflow in chat server example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Jul 9, 2014
1 parent 90a3df4 commit a5977f5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Samples/Chat Example/Chat Example Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ int main(void)
// All messages to all clients come from the server either directly or by being
// relayed from other clients
message2[0]=0;
strcpy(message2, "Server: ");
strcat(message2, message);
const static char prefix[] = "Server: ";
strncpy(message2, prefix, sizeof(message2));
strncat(message2, message, sizeof(message2) - strlen(prefix) - 1);

// message2 is the data to send
// strlen(message2)+1 is to send the null terminator
Expand Down

0 comments on commit a5977f5

Please sign in to comment.