Fixed buffer overrun bug

This commit is contained in:
Kevin Boone
2022-01-25 12:17:34 +00:00
parent 71dc4199e8
commit 10e9ac86df
4 changed files with 10 additions and 5 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
build
epub2txt
*.o

View File

@@ -1,7 +1,7 @@
VERSION := 2.02
VERSION := 2.03
CC := gcc
CFLAGS := -Wall -fPIC -fPIE
LDLAGS := -pie
CFLAGS := -Wall -fPIC -fPIE
LDFLAGS := -pie -s
DESTDIR :=
PREFIX := /usr
BINDIR := /bin

View File

@@ -1,6 +1,6 @@
# epub2txt -- Extract text from EPUB documents
Version 2.02, May 2020
Version 2.03, January 2022
## What is this?
@@ -232,6 +232,7 @@ even approximately, in ASCII.
Date | Change
-----|-------
2.03, Jan 2022 | Fixed a buffer overrun bug
2.02, May 2020 | Updated XML parser
2.01, January 2019 | Various bug fixes
2.0, October 2017 | Completely re-written to do all text processing using 32-bit character arrays, rather than UTF-8 strings, to improve handling of non-English documents.

View File

@@ -573,7 +573,10 @@ WString *xhtml_translate_entity (const WString *entity)
}
}
else
strcpy (out, in);
{
strncpy (out, in, sizeof (out) - 1);
out[sizeof (out) - 1] = 0;
}
free (in);
OUT
return wstring_create_from_utf8 (out);