FreeBSD Bugzilla – Attachment 221266 Details for
Bug 252403
unsafe pointer arithmetic in regcomp()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
suggested patch to fix the issue
regex.diff (text/plain), 1.59 KB, created by
Miod Vallat
on 2021-01-04 07:57:01 UTC
(
hide
)
Description:
suggested patch to fix the issue
Filename:
MIME Type:
Creator:
Miod Vallat
Created:
2021-01-04 07:57:01 UTC
Size:
1.59 KB
patch
obsolete
>diff --git lib/libc/regex/regcomp.c lib/libc/regex/regcomp.c >index 076b9c525a6..970a448b649 100644 >--- lib/libc/regex/regcomp.c >+++ lib/libc/regex/regcomp.c >@@ -175,14 +175,14 @@ static char nuls[10]; /* place to point scanner in event of error */ > * macros for use with parse structure > * BEWARE: these know that the parse structure is named `p' !!! > */ > #define PEEK() (*p->next) > #define PEEK2() (*(p->next+1)) >-#define MORE() (p->next < p->end) >-#define MORE2() (p->next+1 < p->end) >+#define MORE() (p->end - p->next > 0) >+#define MORE2() (p->end - p->next > 1) > #define SEE(c) (MORE() && PEEK() == (c)) >-#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b)) >+#define SEETWO(a, b) (MORE2() && PEEK() == (a) && PEEK2() == (b)) > #define SEESPEC(a) (p->bre ? SEETWO('\\', a) : SEE(a)) > #define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0) > #define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0) > #define EATSPEC(a) (p->bre ? EATTWO('\\', a) : EAT(a)) > #define NEXT() (p->next++) >@@ -1011,19 +1011,21 @@ p_bracket(struct parse *p) > { > cset *cs; > wint_t ch; > > /* Dept of Truly Sickening Special-Case Kludges */ >- if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) { >- EMIT(OBOW, 0); >- NEXTn(6); >- return; >- } >- if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", 6) == 0) { >- EMIT(OEOW, 0); >- NEXTn(6); >- return; >+ if (p->end - p->next > 5) { >+ if (strncmp(p->next, "[:<:]]", 6) == 0) { >+ EMIT(OBOW, 0); >+ NEXTn(6); >+ return; >+ } >+ if (strncmp(p->next, "[:>:]]", 6) == 0) { >+ EMIT(OEOW, 0); >+ NEXTn(6); >+ return; >+ } > } > > if ((cs = allocset(p)) == NULL) > return; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 252403
: 221266