diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2010-10-09 13:16:44 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2010-10-09 13:16:44 +0200 |
commit | 8fe04d4a8ddb81016b03e7c721a532e46de76794 (patch) | |
tree | 75369dbf7209e28a71ba2a1b130b8ddb7bf18e14 /ntlmsubr.c | |
parent | edf9ce362c087be35409de72b4143ea3a6d475d1 (diff) | |
download | fetchmail-8fe04d4a8ddb81016b03e7c721a532e46de76794.tar.gz fetchmail-8fe04d4a8ddb81016b03e7c721a532e46de76794.tar.bz2 fetchmail-8fe04d4a8ddb81016b03e7c721a532e46de76794.zip |
NTLM: cancel properly in case of failure.
Diffstat (limited to 'ntlmsubr.c')
-rw-r--r-- | ntlmsubr.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -2,6 +2,7 @@ #ifdef NTLM_ENABLE #include "fetchmail.h" +#include "i18n.h" #include "ntlm.h" #include "socket.h" @@ -29,8 +30,12 @@ int ntlm_helper(int sock, struct query *ctl, const char *proto) if ((result = gen_recv(sock, msgbuf, sizeof msgbuf))) return result; - if (0 != strcmp(msgbuf, "+ ")) - return PS_AUTHFAIL; + if (msgbuf[0] != '+' && strspn(msgbuf+1, " \t") < strlen(msgbuf+1)) { + if (outlevel >= O_VERBOSE) { + report(stdout, GT_("Warning: received malformed challenge to \"AUTH(ENTICATE) NTLM\"!\n")); + } + goto cancelfail; + } buildSmbNtlmAuthRequest(&request,ctl->remotename,NULL); @@ -46,8 +51,8 @@ int ntlm_helper(int sock, struct query *ctl, const char *proto) strcat(msgbuf,"\r\n"); SockWrite (sock, msgbuf, strlen (msgbuf)); - if ((gen_recv(sock, msgbuf, sizeof msgbuf))) - return result; + if ((result = gen_recv(sock, msgbuf, sizeof msgbuf))) + goto cancelfail; (void)from64tobits (&challenge, msgbuf, sizeof(challenge)); @@ -69,6 +74,14 @@ int ntlm_helper(int sock, struct query *ctl, const char *proto) SockWrite (sock, msgbuf, strlen (msgbuf)); return PS_SUCCESS; + +cancelfail: /* cancel authentication and return failure */ + { + if (outlevel >= O_MONITOR) + report(stdout, "%s> *\n", proto); + SockWrite(sock, "*\r\n", 3); + return result; + } } #endif /* NTLM_ENABLE */ |