Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Buffer Overflow (not really but not terminated by \0) #15

Open
hallard opened this issue Nov 29, 2013 · 1 comment
Open

String Buffer Overflow (not really but not terminated by \0) #15

hallard opened this issue Nov 29, 2013 · 1 comment

Comments

@hallard
Copy link

hallard commented Nov 29, 2013

Hi guys

If a browser send more than 255 char (buffer size) or missing some \n stuff, the buffer could be not terminated by 0, this crashe the string manipulation after and stop the application

Always more robust when we work with string to assure that a zero exists somewhere marking the end of the string.

I added the 3 lines in the code below all is working fine on my side now ;-)

Charles

if (client)
{
// reset input buffer
index = 0;

// Added clearing buffer starting clean
// ===========================
for (int i = 0; i < (sizeof(clientline)); i++)
clientline[i] = '\0';

...
...

// fill url the buffer
if(c != '\n' && c != '\r' && index < BUFSIZE)
{
clientline[index++] = c;
continue;
}

// Add this new line at this point
// =====================
clientline[index] = '\0' ;

@jjg
Copy link
Owner

jjg commented Dec 11, 2013

Thanks for the report @hallard, I'll take a look at this as soon as I can spare a few cycles :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants