diff options
author | pfg <pfg@FreeBSD.org> | 2016-04-23 20:45:09 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2016-04-23 20:45:09 +0000 |
commit | f81f18e8d35e6e105824423c1b152f2b9c9cae32 (patch) | |
tree | bb564760f90d2400b94bb72a4a576da70891683f | |
parent | 98be5b21ef4f00f2078de9e1f8760fa3677992e6 (diff) | |
download | FreeBSD-src-f81f18e8d35e6e105824423c1b152f2b9c9cae32.zip FreeBSD-src-f81f18e8d35e6e105824423c1b152f2b9c9cae32.tar.gz |
regex: prevent two improbable signed integer overflows.
In matcher() we used an integer to index nsub of type size_t.
In print() we used an integer to index nstates of type sopno,
typedef'd long.
In both cases the indexes never take negative values.
Match the types to avoid any error.
MFC after: 5 days
-rw-r--r-- | lib/libc/regex/engine.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c index 436370d..77baa7e 100644 --- a/lib/libc/regex/engine.c +++ b/lib/libc/regex/engine.c @@ -154,7 +154,7 @@ matcher(struct re_guts *g, int eflags) { const char *endp; - int i; + size_t i; struct match mv; struct match *m = &mv; const char *dp = NULL; @@ -1108,7 +1108,7 @@ print(struct match *m, FILE *d) { struct re_guts *g = m->g; - int i; + sopno i; int first = 1; if (!(m->eflags®_TRACE)) |