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

[Argtable3] stack corruption for long arguments (IDFGH-8566) #10016

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/console/argtable3/argtable3.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,11 @@ static void arg_cat(char** pdest, const char* src, size_t* pndest) {
char* end = dest + *pndest;

/*locate null terminator of dest string */
while (dest < end && *dest != 0)
while (dest < end-1 && *dest != 0)
dest++;

/* concat src string to dest string */
while (dest < end && *src != 0)
while (dest < end-1 && *src != 0)
*dest++ = *src++;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

end is past the end of the buffer. end = dest + buffer_size.

i.e. if end is 0x05, the last time would should enter the loop (& increment dest) is when dest is 0x03.

last iteration: 0x03 < 0x04 -> dest will become 0x04


/* null terminate dest string */
Expand Down