Skip to content

realloc is 1 byte short #744

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

Open
msmeissn opened this issue Apr 9, 2025 · 2 comments
Open

realloc is 1 byte short #744

msmeissn opened this issue Apr 9, 2025 · 2 comments

Comments

@msmeissn
Copy link

msmeissn commented Apr 9, 2025

revocationsp + strlen(line) + 1);

the realloc is 1 byte or 2 bytes too short, specifically as revocationsp is incremented by 1 byte more already below.

                                    revocationsp =
                                            revocationsp + strlen(line) + 2;

(CC @dennis-tseng99 )

@msmeissn
Copy link
Author

msmeissn commented Apr 9, 2025

also a bit below there is:

                                    sprintf(revlistentry->revocations +
                                                    revocationsp,
                                            "%s\\n", line); 

weird, line might have a \n already, and is double backslash \n here correct? if this is double backslash n , it needs to be
+3 above

@dennis-tseng99
Copy link
Contributor

dennis-tseng99 commented Apr 13, 2025

@msmeissn Thanks so much.
I think +2, rather than +3, is good enough. Suppose line="abc\n" 4 bytes. realloc(...,strlen(line),2) will allocate 6 bytes which is capable of making sprintf() to add line=3 bytes ,'\' and 'n' 2 bytes pluses extra '\0' byte totally 6 bytes.
ps: line is already removed its '\n' ahead of sprintf() by line[strlen(line) - 1] = 0;

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