On 2021/09/29 21:21, Christian Weisgerber wrote:
> The oft-copied parse.y code declares some variables as "unsigned char *"
> but passes them to functions that take "char *" arguments and doesn't
> make any use of the unsigned property.

btw, those used to be char:

----------------------------
revision 1.628
date: 2013/11/25 12:52:45;  author: benno;  state: Exp;  lines: +7 -7;
use u_char for buffers in yylex, for ctype calls
found by millert@, ok deraadt@
----------------------------

Index: parse.y
===================================================================
RCS file: /cvs/src/sbin/pfctl/parse.y,v
retrieving revision 1.627
retrieving revision 1.628
diff -u -p -r1.627 -r1.628
--- parse.y     22 Nov 2013 04:12:48 -0000      1.627
+++ parse.y     25 Nov 2013 12:52:45 -0000      1.628
@@ -1,4 +1,4 @@
-/*     $OpenBSD: parse.y,v 1.627 2013/11/22 04:12:48 deraadt Exp $     */
+/*     $OpenBSD: parse.y,v 1.628 2013/11/25 12:52:45 benno Exp $       */
 
 /*
  * Copyright (c) 2001 Markus Friedl.  All rights reserved.
@@ -5536,9 +5536,9 @@ lookup(char *s)
 
 #define MAXPUSHBACK    128
 
-char   *parsebuf;
+u_char *parsebuf;
 int     parseindex;
-char    pushback_buffer[MAXPUSHBACK];
+u_char  pushback_buffer[MAXPUSHBACK];
 int     pushback_index = 0;
 
 int
@@ -5630,8 +5630,8 @@ findeol(void)
 int
 yylex(void)
 {
-       char     buf[8096];
-       char    *p, *val;
+       u_char   buf[8096];
+       u_char  *p, *val;
        int      quotec, next, c;
        int      token;
 
@@ -5654,7 +5654,7 @@ top:
                                return (findeol());
                        }
                        if (isalnum(c) || c == '_') {
-                               *p++ = (char)c;
+                               *p++ = c;
                                continue;
                        }
                        *p = '\0';
@@ -5699,7 +5699,7 @@ top:
                                yyerror("string too long");
                                return (findeol());
                        }
-                       *p++ = (char)c;
+                       *p++ = c;
                }
                yylval.v.string = strdup(buf);
                if (yylval.v.string == NULL)

Reply via email to