mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
Unbreak numeric flag parsing. Based on a fix from Jared Yanovich; this
version with millert@. Resolves PR 3677. ok millert@
This commit is contained in:
parent
e21e5b4e74
commit
7dd6850ea4
@ -1,4 +1,4 @@
|
|||||||
/* $OpenBSD: compile.c,v 1.16 2003/10/07 17:56:26 deraadt Exp $ */
|
/* $OpenBSD: compile.c,v 1.17 2004/02/17 16:13:33 otto Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992 Diomidis Spinellis.
|
* Copyright (c) 1992 Diomidis Spinellis.
|
||||||
@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
/* from: static char sccsid[] = "@(#)compile.c 8.2 (Berkeley) 4/28/95"; */
|
/* from: static char sccsid[] = "@(#)compile.c 8.2 (Berkeley) 4/28/95"; */
|
||||||
static char *rcsid = "$OpenBSD: compile.c,v 1.16 2003/10/07 17:56:26 deraadt Exp $";
|
static char *rcsid = "$OpenBSD: compile.c,v 1.17 2004/02/17 16:13:33 otto Exp $";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -496,6 +496,7 @@ static char *
|
|||||||
compile_flags(char *p, struct s_subst *s)
|
compile_flags(char *p, struct s_subst *s)
|
||||||
{
|
{
|
||||||
int gn; /* True if we have seen g or n */
|
int gn; /* True if we have seen g or n */
|
||||||
|
long l;
|
||||||
char wfile[_POSIX2_LINE_MAX + 1], *q;
|
char wfile[_POSIX2_LINE_MAX + 1], *q;
|
||||||
|
|
||||||
s->n = 1; /* Default */
|
s->n = 1; /* Default */
|
||||||
@ -526,9 +527,12 @@ compile_flags(char *p, struct s_subst *s)
|
|||||||
err(COMPILE,
|
err(COMPILE,
|
||||||
"more than one number or 'g' in substitute flags");
|
"more than one number or 'g' in substitute flags");
|
||||||
gn = 1;
|
gn = 1;
|
||||||
/* XXX Check for overflow */
|
l = strtol(p, &p, 10);
|
||||||
s->n = (int)strtol(p, &p, 10);
|
if (l <= 0 || l >= INT_MAX)
|
||||||
break;
|
err(COMPILE,
|
||||||
|
"number in substitute flags out of range");
|
||||||
|
s->n = (int)l;
|
||||||
|
continue;
|
||||||
case 'w':
|
case 'w':
|
||||||
p++;
|
p++;
|
||||||
#ifdef HISTORIC_PRACTICE
|
#ifdef HISTORIC_PRACTICE
|
||||||
|
Loading…
Reference in New Issue
Block a user