Cope with rb_crypt() returning NULL.

This commit is contained in:
Jilles Tjoelker 2013-02-02 00:54:32 +01:00
parent df2516e6d8
commit e69375f3ac
5 changed files with 13 additions and 7 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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);