projects
/
privoxy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
52a711a
)
Also let parse_toggle_state() reject values like '1[insert garbage here]'
author
Fabian Keil
<fk@fabiankeil.de>
Fri, 8 Jul 2011 13:29:22 +0000
(13:29 +0000)
committer
Fabian Keil
<fk@fabiankeil.de>
Fri, 8 Jul 2011 13:29:22 +0000
(13:29 +0000)
loadcfg.c
patch
|
blob
|
history
diff --git
a/loadcfg.c
b/loadcfg.c
index
6f39e17
..
2369cc7
100644
(file)
--- a/
loadcfg.c
+++ b/
loadcfg.c
@@
-1,4
+1,4
@@
-const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.11
3 2011/07/08 13:27:31
fabiankeil Exp $";
+const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.11
4 2011/07/08 13:29:06
fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $
@@
-297,6
+297,7
@@
static int parse_toggle_state(const char *name, const char *value)
{
int toggle_state;
assert(name != NULL);
{
int toggle_state;
assert(name != NULL);
+ assert(value != NULL);
if ((value == NULL) || (*value == '\0'))
{
if ((value == NULL) || (*value == '\0'))
{
@@
-305,7
+306,11
@@
static int parse_toggle_state(const char *name, const char *value)
toggle_state = atoi(value);
toggle_state = atoi(value);
- if ((toggle_state != 0) && (toggle_state != 1))
+ /*
+ * Also check the length as atoi() doesn't mind
+ * garbage after a valid integer, but we do.
+ */
+ if (((toggle_state != 0) && (toggle_state != 1)) || (strlen(value) != 1))
{
log_error(LOG_LEVEL_FATAL,
"Directive %s used with invalid argument '%s'. Use either '0' or '1'.",
{
log_error(LOG_LEVEL_FATAL,
"Directive %s used with invalid argument '%s'. Use either '0' or '1'.",