Thread: Say Links
View Single Post
  #35  
Old 05-22-2009, 04:55 PM
Shendare
Dragon
 
Join Date: Apr 2009
Location: California
Posts: 814
Default

Ooh, yeah, some unstable referencing there.

Using char response[64]; instead of char* response; will solve the main problem by allocating 63 bytes for the phrase (plus one for the null terminator).

The second step would be changing strcpy() so that if someone gets funny and passes a phrase larger than 63 characters you won't be looking at a buffer overflow:

Code:
if (mysql_num_rows(result) == 1)
{
	row = mysql_fetch_row(result);
	strncpy_s(response, sizeof(response), row[0], _TRUNCATE);
}
Reply With Quote