From 8d1eb202bf13dbe23d8379b095f64a10c0204676 Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 16 Jan 2015 18:28:08 +0000 Subject: Add gcc format attributes for yyerror(); fix a few yyerror() calls. Adapted from src parse.y changes by doug@. OK doug@ --- parse.y | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/parse.y b/parse.y index 7df4f98..590bd44 100644 --- a/parse.y +++ b/parse.y @@ -47,7 +47,9 @@ struct file *pushfile(const char *); int popfile(void); int yyparse(void); int yylex(void); -int yyerror(const char *, ...); +int yyerror(const char *, ...) + __attribute__((__format__ (printf, 1, 2))) + __attribute__((__nonnull__ (1))); int kw_cmp(const void *, const void *); int lookup(char *); int lgetc(int); @@ -117,21 +119,21 @@ main : FONTNAME STRING { } | BORDERWIDTH NUMBER { if ($2 < 0 || $2 > UINT_MAX) { - yyerror("invalid borderwidth: %d", $2); + yyerror("invalid borderwidth: %lld", $2); YYERROR; } conf->bwidth = $2; } | MOVEAMOUNT NUMBER { if ($2 < 0 || $2 > INT_MAX) { - yyerror("invalid movemount: %d", $2); + yyerror("invalid movemount: %lld", $2); YYERROR; } conf->mamount = $2; } | SNAPDIST NUMBER { if ($2 < 0 || $2 > INT_MAX) { - yyerror("invalid snapdist: %d", $2); + yyerror("invalid snapdist: %lld", $2); YYERROR; } conf->snapdist = $2; @@ -149,7 +151,7 @@ main : FONTNAME STRING { | AUTOGROUP NUMBER STRING { if ($2 < 0 || $2 > 9) { free($3); - yyerror("invalid autogroup: %d", $2); + yyerror("invalid autogroup: %lld", $2); YYERROR; } conf_autogroup(conf, $2, $3); @@ -174,7 +176,7 @@ main : FONTNAME STRING { $3 < 0 || $3 > INT_MAX || $4 < 0 || $4 > INT_MAX || $5 < 0 || $5 > INT_MAX) { - yyerror("invalid gap: %d %d %d %d", + yyerror("invalid gap: %lld %lld %lld %lld", $2, $3, $4, $5); YYERROR; } -- cgit 1.4.1 From c412f040df05c7221537a598786e0cea4b35167f Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 17 Jan 2015 02:05:03 +0000 Subject: Catch up with src parse.y changes by jsg@: Don't allow embedded nul characters in strings. Fixes a pfctl crash with an anchor name containing an embedded nul found with the afl fuzzer. pfctl parse.y patch from and ok deraadt@ --- parse.y | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parse.y b/parse.y index 590bd44..31d094d 100644 --- a/parse.y +++ b/parse.y @@ -438,6 +438,9 @@ yylex(void) } else if (c == quotec) { *p = '\0'; break; + } else if (c == '\0') { + yyerror("syntax error"); + return (findeol()); } if (p + 1 >= buf + sizeof(buf) - 1) { yyerror("string too long"); -- cgit 1.4.1 From 7936b9b2a7c7c3cc06d3fb60c22ed535b610cd63 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 19 Jan 2015 14:54:16 +0000 Subject: Switch to limits.h; replace MAXPATHLEN and MAXHOSTNAMELEN with PATH_MAX and HOST_NAME_MAX+1, respectively. ok doug@ --- calmwm.c | 3 ++- calmwm.h | 4 ++-- client.c | 3 ++- conf.c | 3 ++- group.c | 3 ++- kbfunc.c | 9 +++++---- menu.c | 3 ++- mousefunc.c | 3 ++- parse.y | 2 +- screen.c | 3 ++- search.c | 5 +++-- util.c | 3 ++- xevents.c | 3 ++- xmalloc.c | 3 ++- xutil.c | 3 ++- 15 files changed, 33 insertions(+), 20 deletions(-) diff --git a/calmwm.c b/calmwm.c index f85c4c2..2fc0a4f 100644 --- a/calmwm.c +++ b/calmwm.c @@ -18,13 +18,14 @@ * $OpenBSD$ */ -#include +#include #include #include #include #include #include +#include #include #include #include diff --git a/calmwm.h b/calmwm.h index 80e2554..0e5652a 100644 --- a/calmwm.h +++ b/calmwm.h @@ -260,7 +260,7 @@ TAILQ_HEAD(mousebinding_q, binding); struct cmd { TAILQ_ENTRY(cmd) entry; char *name; - char path[MAXPATHLEN]; + char path[PATH_MAX]; }; TAILQ_HEAD(cmd_q, cmd); @@ -292,7 +292,7 @@ struct conf { int snapdist; struct gap gap; char *color[CWM_COLOR_NITEMS]; - char known_hosts[MAXPATHLEN]; + char known_hosts[PATH_MAX]; #define CONF_FONT "sans-serif:pixelsize=14:bold" char *font; Cursor cursor[CF_NITEMS]; diff --git a/client.c b/client.c index 1802206..f6aa714 100644 --- a/client.c +++ b/client.c @@ -18,12 +18,13 @@ * $OpenBSD$ */ -#include +#include #include #include #include #include +#include #include #include #include diff --git a/conf.c b/conf.c index 181bf09..8eec4a3 100644 --- a/conf.c +++ b/conf.c @@ -18,12 +18,13 @@ * $OpenBSD$ */ -#include +#include #include #include #include #include +#include #include #include #include diff --git a/group.c b/group.c index 50fb82c..834c2f7 100644 --- a/group.c +++ b/group.c @@ -19,12 +19,13 @@ * $OpenBSD$ */ -#include +#include #include #include #include #include +#include #include #include #include diff --git a/kbfunc.c b/kbfunc.c index c3be2f5..388ead7 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -18,12 +18,13 @@ * $OpenBSD$ */ -#include +#include #include #include #include #include +#include #include #include #include @@ -238,7 +239,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg) #define NPATHS 256 struct screen_ctx *sc = cc->sc; char **ap, *paths[NPATHS], *path, *pathcpy; - char tpath[MAXPATHLEN]; + char tpath[PATH_MAX]; const char *label; DIR *dirp; struct dirent *dp; @@ -323,8 +324,8 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg) struct menu_q menuq; FILE *fp; char *buf, *lbuf, *p; - char hostbuf[MAXHOSTNAMELEN]; - char path[MAXPATHLEN]; + char hostbuf[HOST_NAME_MAX+1]; + char path[PATH_MAX]; int l; size_t len; diff --git a/menu.c b/menu.c index cd84602..f73bc5e 100644 --- a/menu.c +++ b/menu.c @@ -19,12 +19,13 @@ * $OpenBSD$ */ -#include +#include #include #include #include #include +#include #include #include #include diff --git a/mousefunc.c b/mousefunc.c index 1f3cf34..14138a6 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -19,11 +19,12 @@ * $OpenBSD$ */ -#include +#include #include #include #include +#include #include #include #include diff --git a/parse.y b/parse.y index 31d094d..235bca5 100644 --- a/parse.y +++ b/parse.y @@ -21,7 +21,7 @@ %{ -#include +#include #include #include diff --git a/screen.c b/screen.c index 18ffd05..bb7bd9c 100644 --- a/screen.c +++ b/screen.c @@ -18,11 +18,12 @@ * $OpenBSD$ */ -#include +#include #include #include #include +#include #include #include #include diff --git a/search.c b/search.c index f0b22ce..ac9f632 100644 --- a/search.c +++ b/search.c @@ -18,7 +18,7 @@ * $OpenBSD$ */ -#include +#include #include #include @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -172,7 +173,7 @@ search_print_client(struct menu *mi, int list) static void search_match_path(struct menu_q *menuq, struct menu_q *resultq, char *search, int flag) { - char pattern[MAXPATHLEN]; + char pattern[PATH_MAX]; glob_t g; int i; diff --git a/util.c b/util.c index f69f880..0b10795 100644 --- a/util.c +++ b/util.c @@ -18,11 +18,12 @@ * $OpenBSD$ */ -#include +#include #include #include #include +#include #include #include #include diff --git a/xevents.c b/xevents.c index e2b7178..e6ed84d 100644 --- a/xevents.c +++ b/xevents.c @@ -24,11 +24,12 @@ * management of the xevent's. */ -#include +#include #include #include #include +#include #include #include #include diff --git a/xmalloc.c b/xmalloc.c index 6963c96..2db79ab 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -18,11 +18,12 @@ * $OpenBSD$ */ -#include +#include #include #include #include +#include #include #include #include diff --git a/xutil.c b/xutil.c index 70186f8..edc1426 100644 --- a/xutil.c +++ b/xutil.c @@ -18,11 +18,12 @@ * $OpenBSD$ */ -#include +#include #include #include #include +#include #include #include #include -- cgit 1.4.1