X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/763d5e6ad88ef3ba1cd1d7742d060e4f1e54c6b8..637fdea366a8a87024322d283eba89067a403493:/lib/client.c diff --git a/lib/client.c b/lib/client.c index 97dde93..979e54a 100644 --- a/lib/client.c +++ b/lib/client.c @@ -207,11 +207,12 @@ int disorder_connect_sock(disorder_client *c, const char *username, const char *password, const char *ident) { - int fd = -1, fd2 = -1; + int fd = -1, fd2 = -1, nrvec; unsigned char *nonce; size_t nl; const char *res; - char *r; + char *r, **rvec; + const char *algo = "SHA1"; if(!password) { error(0, "no password found"); @@ -243,9 +244,17 @@ int disorder_connect_sock(disorder_client *c, c->ident = xstrdup(ident); if(disorder_simple(c, &r, 0, (const char *)0)) return -1; - if(!(nonce = unhex(r, &nl))) + if(!(rvec = split(r, &nrvec, SPLIT_QUOTES, 0, 0))) + return -1; + if(nrvec > 1) { + algo = *rvec++; + --nrvec; + } + if(!nrvec) + return -1; + if(!(nonce = unhex(*rvec, &nl))) return -1; - if(!(res = authhash(nonce, nl, password))) goto error; + if(!(res = authhash(nonce, nl, password, algo))) goto error; if(disorder_simple(c, 0, "user", username, res, (char *)0)) return -1; c->user = xstrdup(username);