X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=pop%2Fpop_auth.c;h=df6de737565268783bcfb59ef15f37a1f71b03c6;hb=25bf57d598476b329536fa3f748cc0c529fef6bd;hp=51cdeb096997be5f3f8fad9cf06774c9c2607fc1;hpb=cc917eda58cb573cd3f56337dfe088a94e23649c;p=apps%2Fmadmutt.git diff --git a/pop/pop_auth.c b/pop/pop_auth.c index 51cdeb0..df6de73 100644 --- a/pop/pop_auth.c +++ b/pop/pop_auth.c @@ -16,6 +16,9 @@ #include "md5.h" #include "pop.h" +#include "lib/mem.h" +#include "lib/intl.h" + #include #include @@ -103,11 +106,11 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) break; #ifdef USE_SASL2 - if (!mutt_strncmp (inbuf, "+ ", 2) + if (!safe_strncmp (inbuf, "+ ", 2) && sasl_decode64 (inbuf, strlen (inbuf), buf, LONG_STRING - 1, &len) != SASL_OK) #else - if (!mutt_strncmp (inbuf, "+ ", 2) + if (!safe_strncmp (inbuf, "+ ", 2) && sasl_decode64 (inbuf, strlen (inbuf), buf, &len) != SASL_OK) #endif { @@ -150,7 +153,7 @@ static pop_auth_res_t pop_auth_sasl (POP_DATA * pop_data, const char *method) if (rc != SASL_OK) goto bail; - if (!mutt_strncmp (inbuf, "+OK", 3)) { + if (!safe_strncmp (inbuf, "+OK", 3)) { mutt_sasl_setup_conn (pop_data->conn, saslconn); return POP_A_SUCCESS; } @@ -159,7 +162,7 @@ bail: sasl_dispose (&saslconn); /* terminate SASL sessoin if the last responce is not +OK nor -ERR */ - if (!mutt_strncmp (inbuf, "+ ", 2)) { + if (!safe_strncmp (inbuf, "+ ", 2)) { snprintf (buf, sizeof (buf), "*\r\n"); if (pop_query (pop_data, buf, sizeof (buf)) == PQ_NOT_CONNECTED) return POP_A_SOCKET; @@ -235,7 +238,7 @@ static pop_auth_res_t pop_auth_user (POP_DATA * pop_data, const char *method) char buf[LONG_STRING]; pop_query_status ret; - if (pop_data->cmd_user == USER_NOT_AVAILABLE) + if (pop_data->cmd_user == CMD_NOT_AVAILABLE) return POP_A_UNAVAIL; mutt_message _("Logging in..."); @@ -243,15 +246,15 @@ static pop_auth_res_t pop_auth_user (POP_DATA * pop_data, const char *method) snprintf (buf, sizeof (buf), "USER %s\r\n", pop_data->conn->account.user); ret = pop_query (pop_data, buf, sizeof (buf)); - if (pop_data->cmd_user == USER_UNKNOWN) { + if (pop_data->cmd_user == CMD_UNKNOWN) { if (ret == PQ_OK) { - pop_data->cmd_user = USER_AVAILABLE; + pop_data->cmd_user = CMD_AVAILABLE; dprint (1, (debugfile, "pop_auth_user: set USER capability\n")); } if (ret == PQ_ERR) { - pop_data->cmd_user = USER_NOT_AVAILABLE; + pop_data->cmd_user = CMD_NOT_AVAILABLE; dprint (1, (debugfile, "pop_auth_user: unset USER capability\n")); snprintf (pop_data->err_msg, sizeof (pop_data->err_msg), @@ -298,7 +301,7 @@ static pop_auth_t pop_authenticators[] = { * -2 - login failed, * -3 - authentication canceled. */ -int pop_authenticate (POP_DATA * pop_data) +pop_query_status pop_authenticate (POP_DATA * pop_data) { ACCOUNT *acct = &pop_data->conn->account; pop_auth_t *authenticator; @@ -310,7 +313,7 @@ int pop_authenticate (POP_DATA * pop_data) if (mutt_account_getuser (acct) || !acct->user[0] || mutt_account_getpass (acct) || !acct->pass[0]) - return -3; + return PFD_FUNCT_ERROR; if (PopAuthenticators && *PopAuthenticators) { /* Try user-specified list of authentication methods */ @@ -330,12 +333,12 @@ int pop_authenticate (POP_DATA * pop_data) ret = authenticator->authenticate (pop_data, method); if (ret == POP_A_SOCKET) switch (pop_connect (pop_data)) { - case 0: + case PQ_OK: { ret = authenticator->authenticate (pop_data, method); break; } - case -2: + case PQ_ERR: ret = POP_A_FAILURE; } @@ -365,13 +368,13 @@ int pop_authenticate (POP_DATA * pop_data) ret = authenticator->authenticate (pop_data, authenticator->method); if (ret == POP_A_SOCKET) switch (pop_connect (pop_data)) { - case 0: + case PQ_OK: { ret = authenticator->authenticate (pop_data, authenticator->method); break; } - case -2: + case PQ_ERR: ret = POP_A_FAILURE; } @@ -387,13 +390,13 @@ int pop_authenticate (POP_DATA * pop_data) switch (ret) { case POP_A_SUCCESS: - return 0; + return PQ_OK; case POP_A_SOCKET: - return -1; + return PQ_NOT_CONNECTED; case POP_A_UNAVAIL: if (!attempts) mutt_error (_("No authenticators available")); } - return -2; + return PQ_ERR; }