⬢ DragonFlyBSD Kernel Audit
DF-5718 / wrestrict_shim.c
← back to finding ↓ download raw
/*
 * DF-5718 - compiler proof that the netgraph parser's strcpy usage violates
 * the C restrict contract. Mirrors exactly:
 *
 *   sys/netgraph/netgraph/ng_parse.c:1572   strcpy(p, p + 1);
 *   sys/netgraph/netgraph/ng_parse.c:1621   strcpy(p, v);       (v > p)
 *   sys/netgraph7/netgraph/ng_parse.c:1764/1813 (same code)
 *
 * GCC >= 8 flags this as undefined behavior with -Wrestrict.
 */
#include <string.h>

void
ng_parse_escapes(char *p)
{
	char *v = p + 2;

	strcpy(p, p + 1);	/* ng_parse.c:1572 / ng7:1764 */
	strcpy(p, v);		/* ng_parse.c:1621 / ng7:1813 */
}