Fix segfault in yacc

The patch to heirloom-devtool's yacc used sprintf instead of snprintf.
This incompatibility causes a segfault when those code paths are hit.
Fixing this allows yacc to compile more grammars, and may allow some
packages to drop dependency on bison in favor of yacc.
This commit is contained in:
Emily Trau 2023-05-01 20:40:32 +10:00
parent bd7ad7e8ae
commit 2c0a1d39d9
2 changed files with 4 additions and 3 deletions

View file

@ -1,5 +1,6 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2021 fosslinux <fosslinux@aussies.space>
SPDX-FileCopyrightText: 2023 Emily Trau <emily@downunderctf.com>
SPDX-License-Identifier: CDDL-1.0
@ -227,7 +228,7 @@ diff -U3 -r yacc/y1.c yacc/y1.c
- q = chcopy(q, L" (");
- swprintf(q, q + isize - sarr, L"%d)", -i);
+ q = chcopy(q, " (");
+ sprintf(q, q + isize - sarr, "%d)", -i);
+ snprintf(q, q + isize - sarr, "%d)", -i);
}
return (sarr);
}
@ -393,7 +394,7 @@ diff -U3 -r yacc/y2.c yacc/y2.c
lrprnt(); /* dump lhs, rhs */
- swprintf(actname, sizeof actname,
- L"$$%d", nprod);
+ sprintf(actname, sizeof actname,
+ snprintf(actname, sizeof actname,
+ "$$%d", nprod);
/*
* make it nonterminal