diff options
author | 2005-12-10 05:35:15 +0000 | |
---|---|---|
committer | 2005-12-10 05:35:15 +0000 | |
commit | 5beea806f215d0c8f0115d0905e1c2db21195200 (patch) | |
tree | daecb1b2ad358b4227288bf7da5f74b6208756e1 | |
parent | ANSI functions. (diff) | |
download | wireguard-openbsd-5beea806f215d0c8f0115d0905e1c2db21195200.tar.xz wireguard-openbsd-5beea806f215d0c8f0115d0905e1c2db21195200.zip |
Fix a crash when enum bitfields are encountered. Reported by marc on
sparc but we really should see the crash on any arch. Lots of places
in the code assume that if tspec == ENUM that they can touch t_enum,
so when we see an ENUM bitfield, we coerce the type to INT or UINT.
We also clear the t_isenum flag and the t_proto flag any time we
invalidate the data in the union. We should be stricter about checking
t_isenum everywhere, but that is a bigger job.
-rw-r--r-- | usr.bin/xlint/lint1/decl.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index 8d4951d8f1e..0d61200b78d 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: decl.c,v 1.15 2005/11/23 18:47:41 cloder Exp $ */ +/* $OpenBSD: decl.c,v 1.16 2005/12/10 05:35:15 cloder Exp $ */ /* $NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: decl.c,v 1.15 2005/11/23 18:47:41 cloder Exp $"; +static char rcsid[] = "$OpenBSD: decl.c,v 1.16 2005/12/10 05:35:15 cloder Exp $"; #endif #include <sys/param.h> @@ -1046,6 +1046,12 @@ decl1str(sym_t *dsym) /* nonportable bit-field type */ warning(34); } + if (isutyp(t)) + tp->t_tspec = UINT; + else + tp->t_tspec = INT; + + tp->t_isenum = 0; } else if (t == INT && dcs->d_smod == NOTSPEC) { if (pflag) { /* nonportable bit-field type */ @@ -1156,6 +1162,8 @@ bitfield(sym_t *dsym, int len) } dsym->s_type = duptyp(dsym->s_type); dsym->s_type->t_isfield = 1; + dsym->s_type->t_proto = 0; + dsym->s_type->t_isenum = 0; dsym->s_type->t_flen = len; dsym->s_field = 1; return (dsym); |