Skip to content

Commit

Permalink
Fix a buffer overflow issue with fuzzer-generated code (Issue #5)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Jul 3, 2019
1 parent 978192e commit 19532db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ CC = gcc
CFLAGS = $(OPTIM) -Wall '-DVERSION="$(VERSION)"' $(OPTIONS)
LDFLAGS = $(OPTIM)
LIBS = -lmxml -lz -lm
OPTIM = -Os -g
#OPTIM = -g -fsanitize=address
#OPTIM = -Os -g
OPTIM = -g -fsanitize=address
OPTIONS =
#OPTIONS = -DDEBUG=1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Changes in v3.2

- The default HTML stylesheet no longer puts an outline box around monospaced
text (Issue #2)
- Fixed a buffer overflow issue with fuzzer-generated "code" (Issue #5)
- Now use the base name of the cover image filename in HTML output.
- Fixed some markdown parsing issues.

Expand Down
2 changes: 1 addition & 1 deletion codedoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ add_variable(mxml_node_t *parent, /* I - Parent node */
{
string = mxmlGetText(node, &whitespace);

if (whitespace && bufptr > buffer)
if (whitespace && bufptr > buffer && bufptr < (buffer + sizeof(buffer) - 1))
*bufptr++ = ' ';

strlcpy(bufptr, string, sizeof(buffer) - (size_t)(bufptr - buffer));
Expand Down

0 comments on commit 19532db

Please sign in to comment.