Share

HTML Tidy

Tracker: Bugs

5 Null termination problem in tidySaveString - ID: 2893644
Last Update: Attachment added ( kevinoid )

Note: This could be considered either a documentation problem or a code
problem.

The user-provided buffer to tidySaveString is not null-terminated. In
tidyDocSaveString the user-provided buffer is filled with the bytes in the
outbuf and the size is set to the space used in outbuf. However, outbuf is
not null terminated, so if the user provides a buffer which is the size
returned in buflen, they will get a non-null-terminated string. If this is
the intended behavior, I strongly suggest adding large warnings that buflen
is the length of the content that will be stored in the buffer and that the
user must null-terminate the string after it is returned. Otherwise, I
suggest changing tidyDocSaveString to null-terminate the string and return
the size of the buffer space required in buflen. I have attached a patch
which does this.


Kevin Locke ( kevinoid ) - 2009-11-07 00:25

5

Open

None

Nobody/Anonymous

TidyLib APIs

Current - all platforms

Public


Comments

No follow-up comments have been posted.

Attached File ( 1 )

Filename Description Download
docSaveString-fix_null_termination.patch Fix the null-termination behavior of tidySaveString Download

Change ( 1 )

Field Old Value Date By
File Added 349861: docSaveString-fix_null_termination.patch 2009-11-07 00:25 kevinoid