From c8bce629dc68f1e1315cceadd4a6d8d45cbadec1 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 6 May 2013 19:09:19 +0000 Subject: negative values for borderwith, moveamount, snapdist and gap are configuration errors, so warn and load defaults. --- parse.y | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 8dc1dd0..b0d7395 100644 --- a/parse.y +++ b/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.40 2013/04/17 13:30:38 okan Exp $ */ +/* $OpenBSD: parse.y,v 1.41 2013/05/06 19:09:19 okan Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -117,12 +117,24 @@ main : FONTNAME STRING { conf->flags |= CONF_STICKY_GROUPS; } | BORDERWIDTH NUMBER { + if ($2 < 0) { + yyerror("invalid borderwidth: %d", $2); + YYERROR; + } conf->bwidth = $2; } | MOVEAMOUNT NUMBER { + if ($2 < 0) { + yyerror("invalid movemount: %d", $2); + YYERROR; + } conf->mamount = $2; } | SNAPDIST NUMBER { + if ($2 < 0) { + yyerror("invalid snapdist: %d", $2); + YYERROR; + } conf->snapdist = $2; } | COMMAND STRING string { @@ -133,10 +145,9 @@ main : FONTNAME STRING { | AUTOGROUP NUMBER STRING { if ($2 < 0 || $2 > 9) { free($3); - yyerror("autogroup number out of range: %d", $2); + yyerror("invalid autogroup: %d", $2); YYERROR; } - conf_autogroup(conf, $2, $3); free($3); } @@ -150,6 +161,11 @@ main : FONTNAME STRING { free($3); } | GAP NUMBER NUMBER NUMBER NUMBER { + if ($2 < 0 || $3 < 0 || $4 < 0 || $5 < 0) { + yyerror("invalid gap: %d %d %d %d", + $2, $3, $4, $5); + YYERROR; + } conf->gap.top = $2; conf->gap.bottom = $3; conf->gap.left = $4; -- cgit v1.2.3-2-gb3c3