diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2014-01-28 20:22:22 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2014-01-28 20:22:22 +0000 |
commit | a240c48f4717d20660a7fd08618e58c9734c53fc (patch) | |
tree | 2d77117bb78e0338604bc62737c7220a898b3a43 /app | |
parent | 1ed891d8ed7010f6959da2b6587c4115d383c5a3 (diff) |
Check ignore windowname for truncation and provide user feedback during
config parse; based on a discussion with Tiago Cunha.
Diffstat (limited to 'app')
-rw-r--r-- | app/cwm/calmwm.h | 4 | ||||
-rw-r--r-- | app/cwm/conf.c | 8 | ||||
-rw-r--r-- | app/cwm/parse.y | 8 |
3 files changed, 13 insertions, 7 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 9cc96bc56..729c04890 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.247 2014/01/22 21:48:27 okan Exp $ + * $OpenBSD: calmwm.h,v 1.248 2014/01/28 20:22:21 okan Exp $ */ #ifndef _CALMWM_H_ @@ -528,7 +528,7 @@ void conf_cursor(struct conf *); void conf_grab_kbd(Window); void conf_grab_mouse(Window); void conf_init(struct conf *); -void conf_ignore(struct conf *, const char *); +int conf_ignore(struct conf *, const char *); void conf_screen(struct screen_ctx *); void xev_process(void); diff --git a/app/cwm/conf.c b/app/cwm/conf.c index 9f05d9e6a..a2ac6b8da 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.162 2014/01/23 17:13:38 okan Exp $ + * $OpenBSD: conf.c,v 1.163 2014/01/28 20:22:21 okan Exp $ */ #include <sys/param.h> @@ -73,16 +73,18 @@ conf_autogroup(struct conf *c, int no, const char *val) TAILQ_INSERT_TAIL(&c->autogroupq, aw, entry); } -void +int conf_ignore(struct conf *c, const char *val) { struct winmatch *wm; wm = xcalloc(1, sizeof(*wm)); - (void)strlcpy(wm->title, val, sizeof(wm->title)); + if (strlcpy(wm->title, val, sizeof(wm->title)) >= sizeof(wm->title)) + return (0); TAILQ_INSERT_TAIL(&c->ignoreq, wm, entry); + return (1); } static const char *color_binds[] = { diff --git a/app/cwm/parse.y b/app/cwm/parse.y index 33d49a08b..f218a13bc 100644 --- a/app/cwm/parse.y +++ b/app/cwm/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.54 2014/01/28 00:42:20 okan Exp $ */ +/* $OpenBSD: parse.y,v 1.55 2014/01/28 20:22:21 okan Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -151,7 +151,11 @@ main : FONTNAME STRING { free($3); } | IGNORE STRING { - conf_ignore(conf, $2); + if (!conf_ignore(conf, $2)) { + yyerror("ignore windowname too long"); + free($2); + YYERROR; + } free($2); } | BIND STRING string { |