From e69375f3ac54b843590fa850f58fa4a2972f28b6 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Sat, 2 Feb 2013 00:54:32 +0100 Subject: [PATCH] Cope with rb_crypt() returning NULL. --- extensions/m_mkpasswd.c | 8 ++++++-- extensions/m_webirc.c | 2 +- modules/m_oper.c | 2 +- src/s_serv.c | 6 ++++-- src/s_user.c | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/extensions/m_mkpasswd.c b/extensions/m_mkpasswd.c index b8fad447..a277cfa4 100644 --- a/extensions/m_mkpasswd.c +++ b/extensions/m_mkpasswd.c @@ -46,6 +46,7 @@ m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const cha { static time_t last_used = 0; char *salt; + const char *crypted; const char *hashtype; const char hashdefault[] = "SHA512"; @@ -82,7 +83,8 @@ m_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const cha return 0; } - sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt)); + crypted = rb_crypt(parv[1], salt); + sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], crypted ? crypted : "???"); return 0; } @@ -94,6 +96,7 @@ static int mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { char *salt; + const char *crypted; const char *hashtype; const char hashdefault[] = "SHA512"; @@ -121,7 +124,8 @@ mo_mkpasswd(struct Client *client_p, struct Client *source_p, int parc, const ch return 0; } - sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], rb_crypt(parv[1], salt)); + crypted = rb_crypt(parv[1], salt); + sendto_one_notice(source_p, ":Hash [%s] for %s: %s", hashtype, parv[1], crypted ? crypted : "???"); return 0; } diff --git a/extensions/m_webirc.c b/extensions/m_webirc.c index 6f57e920..ea6bc362 100644 --- a/extensions/m_webirc.c +++ b/extensions/m_webirc.c @@ -110,7 +110,7 @@ mr_webirc(struct Client *client_p, struct Client *source_p, int parc, const char else encr = parv[1]; - if (strcmp(encr, aconf->passwd)) + if (encr == NULL || strcmp(encr, aconf->passwd)) { sendto_one(source_p, "NOTICE * :CGI:IRC password incorrect"); return 0; diff --git a/modules/m_oper.c b/modules/m_oper.c index 96794a16..75167ae1 100644 --- a/modules/m_oper.c +++ b/modules/m_oper.c @@ -196,7 +196,7 @@ match_oper_password(const char *password, struct oper_conf *oper_p) else encr = password; - if(strcmp(encr, oper_p->passwd) == 0) + if(encr != NULL && strcmp(encr, oper_p->passwd) == 0) return YES; else return NO; diff --git a/src/s_serv.c b/src/s_serv.c index a6e8b432..7cb1715d 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -326,6 +326,7 @@ check_server(const char *name, struct Client *client_p) struct server_conf *tmp_p; rb_dlink_node *ptr; int error = -1; + const char *encr; s_assert(NULL != client_p); if(client_p == NULL) @@ -360,8 +361,9 @@ check_server(const char *name, struct Client *client_p) { if(ServerConfEncrypted(tmp_p)) { - if(!strcmp(tmp_p->passwd, rb_crypt(client_p->localClient->passwd, - tmp_p->passwd))) + encr = rb_crypt(client_p->localClient->passwd, + tmp_p->passwd); + if(encr != NULL && !strcmp(tmp_p->passwd, encr)) { server_p = tmp_p; break; diff --git a/src/s_user.c b/src/s_user.c index e6fc1151..92973172 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -373,7 +373,7 @@ register_local_user(struct Client *client_p, struct Client *source_p, const char else encr = source_p->localClient->passwd; - if(strcmp(encr, aconf->passwd)) + if(encr == NULL || strcmp(encr, aconf->passwd)) { ServerStats.is_ref++; sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, source_p->name);