Skip to content

realloc is 1 byte short #744

Open
Open

Description

@msmeissn

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 )

Activity

  1. msmeissn commented on Apr 9, 2025

    @msmeissn
    Author

    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

  2. dennis-tseng99 commented on Apr 13, 2025

    @dennis-tseng99
    Contributor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions