mirror of https://github.com/moparisthebest/curl
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.
This commit is contained in:
parent
4e2ac742c9
commit
fe165c69de
|
@ -58,7 +58,7 @@
|
||||||
|
|
||||||
/* Get user and password from .netrc when given a machine name */
|
/* Get user and password from .netrc when given a machine name */
|
||||||
|
|
||||||
enum {
|
enum host_lookup_state {
|
||||||
NOTHING,
|
NOTHING,
|
||||||
HOSTFOUND, /* the 'machine' keyword was found */
|
HOSTFOUND, /* the 'machine' keyword was found */
|
||||||
HOSTCOMPLETE, /* the machine name following the keyword was found too */
|
HOSTCOMPLETE, /* the machine name following the keyword was found too */
|
||||||
|
@ -83,7 +83,7 @@ int Curl_parsenetrc(const char *host,
|
||||||
char *home = NULL;
|
char *home = NULL;
|
||||||
bool home_alloc = FALSE;
|
bool home_alloc = FALSE;
|
||||||
bool netrc_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_login=0; /* Found a login keyword */
|
||||||
char state_password=0; /* Found a password keyword */
|
char state_password=0; /* Found a password keyword */
|
||||||
|
@ -210,6 +210,10 @@ int Curl_parsenetrc(const char *host,
|
||||||
state_our_login = FALSE;
|
state_our_login = FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case HOSTCOMPLETE:
|
||||||
|
case HOSTEND:
|
||||||
|
/* Should not be reached. */
|
||||||
|
DEBUGASSERT(0);
|
||||||
} /* switch (state) */
|
} /* switch (state) */
|
||||||
|
|
||||||
tok = strtok_r(NULL, " \t\n", &tok_buf);
|
tok = strtok_r(NULL, " \t\n", &tok_buf);
|
||||||
|
|
Loading…
Reference in New Issue