Module Name: src
Committed By: rillig
Date: Sat Jul 3 21:18:41 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: cgram.y
Log Message:
lint: guard against segmentation fault when parsing struct
Found by afl. The code that triggers this case is:
struct{const}
To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/usr.bin/xlint/lint1/cgram.y
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.248 src/usr.bin/xlint/lint1/cgram.y:1.249
--- src/usr.bin/xlint/lint1/cgram.y:1.248 Tue Jun 29 05:41:45 2021
+++ src/usr.bin/xlint/lint1/cgram.y Sat Jul 3 21:18:40 2021
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.248 2021/06/29 05:41:45 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.249 2021/07/03 21:18:40 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.248 2021/06/29 05:41:45 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.249 2021/07/03 21:18:40 rillig Exp $");
#endif
#include <limits.h>
@@ -832,6 +832,7 @@ member_declaration:
/* anonymous struct/union members is a C9X feature */
warning(49);
/* add all the members of the anonymous struct/union */
+ lint_assert(is_struct_or_union(dcs->d_type->t_tspec));
$$ = dcs->d_type->t_str->sou_first_member;
anonymize($$);
}