aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Chaffraix <julien.chaffraix@gmail.com>2011-01-28 08:20:37 -0800
committerJulien Chaffraix <julien.chaffraix@gmail.com>2011-02-07 20:15:35 -0800
commitfe165c69dee2b347d1f54094e2751ea3fbd24297 (patch)
tree5a7cf6727717c7afeefc1b24143a429f519e855c
parent4e2ac742c9af30533afa2605db5527dbfab0ee35 (diff)
netrc: Tightened up the type checks.
The state should not be anonymous so that we can check if the values are fine. Added 2 unreachables states to the switch as a result of this change.
-rw-r--r--lib/netrc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/netrc.c b/lib/netrc.c
index e9443253e..1934d6a69 100644
--- a/lib/netrc.c
+++ b/lib/netrc.c
@@ -58,7 +58,7 @@
/* Get user and password from .netrc when given a machine name */
-enum {
+enum host_lookup_state {
NOTHING,
HOSTFOUND, /* the 'machine' keyword was found */
HOSTCOMPLETE, /* the machine name following the keyword was found too */
@@ -83,7 +83,7 @@ int Curl_parsenetrc(const char *host,
char *home = NULL;
bool home_alloc = FALSE;
bool netrc_alloc = FALSE;
- int state=NOTHING;
+ enum host_lookup_state state=NOTHING;
char state_login=0; /* Found a login keyword */
char state_password=0; /* Found a password keyword */
@@ -210,6 +210,10 @@ int Curl_parsenetrc(const char *host,
state_our_login = FALSE;
}
break;
+ case HOSTCOMPLETE:
+ case HOSTEND:
+ /* Should not be reached. */
+ DEBUGASSERT(0);
} /* switch (state) */
tok = strtok_r(NULL, " \t\n", &tok_buf);