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.
Nobody/Anonymous
TidyLib APIs
Current - all platforms
Public
| Filename | Description | Download |
|---|---|---|
| docSaveString-fix_null_termination.patch | Fix the null-termination behavior of tidySaveString | Download |
| Field | Old Value | Date | By |
|---|---|---|---|
| File Added | 349861: docSaveString-fix_null_termination.patch | 2009-11-07 00:25 | kevinoid |