about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-05-06 19:09:19 +0000
committerokan <okan>2013-05-06 19:09:19 +0000
commit1a06f09fa0e1a92d98757f1d9d0a001ecf3e3bb4 (patch)
tree9c5f638806f912e51c8518319943dd8fe7651cee
parent1db7cc2a18d2d3665a4d589d9bc39312eca42268 (diff)
downloadcwm-1a06f09fa0e1a92d98757f1d9d0a001ecf3e3bb4.tar.gz
cwm-1a06f09fa0e1a92d98757f1d9d0a001ecf3e3bb4.tar.xz
cwm-1a06f09fa0e1a92d98757f1d9d0a001ecf3e3bb4.zip
negative values for borderwith, moveamount, snapdist and gap are
configuration errors, so warn and load defaults.
-rw-r--r--parse.y20
1 files changed, 18 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 2708948..9de56da 100644
--- a/parse.y
+++ b/parse.y
@@ -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;