error on parse_condition pr #680
The while(s[sidx]) { ... was acting as while(1), but the
loop body contained appropriate checks and returns to
function correctly.
Fixes #680
This commit is contained in:
+19
-17
@@ -2410,7 +2410,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
|||||||
return parse_condition(s, sidx);
|
return parse_condition(s, sidx);
|
||||||
|
|
||||||
++sidx;
|
++sidx;
|
||||||
while (s[sidx]) {
|
while (s[sidx][0]) {
|
||||||
char buf[BUFSZ], **subfields;
|
char buf[BUFSZ], **subfields;
|
||||||
int sf = 0; /* subfield count */
|
int sf = 0; /* subfield count */
|
||||||
int kidx;
|
int kidx;
|
||||||
@@ -2419,11 +2419,11 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
|||||||
percent = numeric = always = FALSE;
|
percent = numeric = always = FALSE;
|
||||||
down = up = changed = FALSE;
|
down = up = changed = FALSE;
|
||||||
gt = ge = eq = le = lt = txtval = FALSE;
|
gt = ge = eq = le = lt = txtval = FALSE;
|
||||||
|
#if 0
|
||||||
/* threshold value */
|
/* threshold value - return on empty string */
|
||||||
if (!s[sidx][0])
|
if (!s[sidx][0])
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#endif
|
||||||
memset((genericptr_t) &hilite, 0, sizeof (struct hilite_s));
|
memset((genericptr_t) &hilite, 0, sizeof (struct hilite_s));
|
||||||
hilite.set = FALSE; /* mark it "unset" */
|
hilite.set = FALSE; /* mark it "unset" */
|
||||||
hilite.fld = fld;
|
hilite.fld = fld;
|
||||||
@@ -2600,8 +2600,10 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
|||||||
else {
|
else {
|
||||||
int c = match_str2clr(subfields[i]);
|
int c = match_str2clr(subfields[i]);
|
||||||
|
|
||||||
if (c >= CLR_MAX || coloridx != -1)
|
if (c >= CLR_MAX || coloridx != -1) {
|
||||||
|
config_error_add("bad color '%d %d'", c, coloridx);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
coloridx = c;
|
coloridx = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2640,7 +2642,7 @@ parse_status_hl2(char (*s)[QBUFSZ], boolean from_configfile)
|
|||||||
sidx++;
|
sidx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return (successes > 0);
|
||||||
}
|
}
|
||||||
#endif /* STATUS_HILITES */
|
#endif /* STATUS_HILITES */
|
||||||
|
|
||||||
@@ -2776,7 +2778,7 @@ parse_condition(char (*s)[QBUFSZ], int sidx)
|
|||||||
int coloridx = NO_COLOR;
|
int coloridx = NO_COLOR;
|
||||||
char *tmp, *how;
|
char *tmp, *how;
|
||||||
unsigned long conditions_bitmask = 0UL;
|
unsigned long conditions_bitmask = 0UL;
|
||||||
boolean success = FALSE;
|
boolean result = FALSE;
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -2794,17 +2796,15 @@ parse_condition(char (*s)[QBUFSZ], int sidx)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
sidx++;
|
sidx++;
|
||||||
while(s[sidx]) {
|
if (!s[sidx][0]) {
|
||||||
|
config_error_add("Missing condition(s)");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
while (s[sidx][0]) {
|
||||||
int sf = 0; /* subfield count */
|
int sf = 0; /* subfield count */
|
||||||
char buf[BUFSZ], **subfields;
|
char buf[BUFSZ], **subfields;
|
||||||
|
|
||||||
tmp = s[sidx];
|
tmp = s[sidx];
|
||||||
if (!*tmp) {
|
|
||||||
if (!success)
|
|
||||||
config_error_add("Missing condition(s)");
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
Strcpy(buf, tmp);
|
Strcpy(buf, tmp);
|
||||||
conditions_bitmask = str2conditionbitmask(buf);
|
conditions_bitmask = str2conditionbitmask(buf);
|
||||||
|
|
||||||
@@ -2875,8 +2875,10 @@ parse_condition(char (*s)[QBUFSZ], int sidx)
|
|||||||
} else {
|
} else {
|
||||||
int k = match_str2clr(subfields[i]);
|
int k = match_str2clr(subfields[i]);
|
||||||
|
|
||||||
if (k >= CLR_MAX)
|
if (k >= CLR_MAX) {
|
||||||
|
config_error_add("bad color %d", k);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
coloridx = k;
|
coloridx = k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2884,10 +2886,10 @@ parse_condition(char (*s)[QBUFSZ], int sidx)
|
|||||||
condition array according to color chosen as index */
|
condition array according to color chosen as index */
|
||||||
|
|
||||||
g.cond_hilites[coloridx] |= conditions_bitmask;
|
g.cond_hilites[coloridx] |= conditions_bitmask;
|
||||||
success = TRUE;
|
result = TRUE;
|
||||||
sidx++;
|
sidx++;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user