Skip to content

Commit

Permalink
httpreq: in cmd_setauth check if parameter was given
Browse files Browse the repository at this point in the history
  • Loading branch information
cspiel1 committed Dec 1, 2020
1 parent 1a9b9c7 commit eadf967
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions modules/httpreq/httpreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,16 @@ static int cmd_setauth(struct re_printf *pf, void *arg)
if (err)
return err;

err = re_regex(carg->prm, strlen(carg->prm), "[^ ]* [^ ]*",
&user, &pass);
if (err)
err = re_regex(carg->prm, strlen(carg->prm), "[^ ]*", &user);
if (carg->prm) {
err = re_regex(carg->prm, strlen(carg->prm), "[^ ]* [^ ]*",
&user, &pass);
if (err)
err = re_regex(carg->prm, strlen(carg->prm), "[^ ]*",
&user);
} else {
re_hprintf(pf, "Usage:\nhttp_setauth <user> [pass]\n");
return err;
}

return http_reqconn_set_auth(d->conn,
pl_isset(&user) ? &user : NULL,
Expand Down

0 comments on commit eadf967

Please sign in to comment.