mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-03-25 10:50:08 +03:00
error: Don't move past current position
Make sure that we never move past the current position in xmlParserPrintFileContextInternal. Found with libFuzzer and -fsanitize=implicit-conversion.
This commit is contained in:
parent
608c65bb8e
commit
d9a8dab3a3
8
error.c
8
error.c
@ -190,10 +190,12 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
|
||||
}
|
||||
n = 0;
|
||||
/* search backwards for beginning-of-line (to max buff size) */
|
||||
while ((n++ < (sizeof(content)-1)) && (cur > base) &&
|
||||
(*(cur) != '\n') && (*(cur) != '\r'))
|
||||
while ((n < sizeof(content) - 1) && (cur > base) &&
|
||||
(*cur != '\n') && (*cur != '\r')) {
|
||||
cur--;
|
||||
if ((*(cur) == '\n') || (*(cur) == '\r')) {
|
||||
n++;
|
||||
}
|
||||
if ((n > 0) && ((*cur == '\n') || (*cur == '\r'))) {
|
||||
cur++;
|
||||
} else {
|
||||
/* skip over continuation bytes */
|
||||
|
Loading…
x
Reference in New Issue
Block a user