Skip to content

Commit 00c6490

Browse files
committed
BR3392776: parser: parse_line -- fix unitialized memory access
Andrew reported that we may access unitialized memory > SUMMARY: MemorySanitizer: use-of-uninitialized-value nasm/asm/parser.c:982:41 in parse_line It turns out that in case of malformed data the expression is terminator itself so we should not "lookup ahead" for next one. Thus test for first expression initially and if test passes check for terminator. Reported-by: Andrew Bao <xiaobaozidi@gmail.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
1 parent 3a81150 commit 00c6490

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

asm/parser.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -979,13 +979,12 @@ insn *parse_line(char *buffer, insn *result)
979979
/*
980980
* Process the segment override.
981981
*/
982-
if (value[1].type != 0 ||
983-
value->value != 1 ||
984-
!IS_SREG(value->type))
982+
if (!IS_SREG(value->type) || value->value != 1 ||
983+
value[1].type != 0) {
985984
nasm_nonfatal("invalid segment override");
986-
else if (result->prefixes[PPS_SEG])
985+
} else if (result->prefixes[PPS_SEG]) {
987986
nasm_nonfatal("instruction has conflicting segment overrides");
988-
else {
987+
} else {
989988
result->prefixes[PPS_SEG] = value->type;
990989
if (IS_FSGS(value->type))
991990
op->eaflags |= EAF_FSGS;

0 commit comments

Comments
 (0)