chat: fix segfault when domain is not provided

Running xmppipe in chat mode without a full jid:

    xmppipe --chat --output foo

Caused a segfault when a NULL domain was passed to
xmpp_stanza_set_attribute(). The libstrophe functions do not check for
NULL and so crash calling strlen(NULL).

Set the jid's domain from the user's username. If the user's jid is
user@example.com:

    # expanded to foo@example.com
    xmppipe --chat --output foo
master
Michael Santos 6 years ago
parent 29280e2edc
commit 25dbece040

@ -270,6 +270,13 @@ main(int argc, char **argv)
state->out = xmppipe_strdup(state->room);
state->mucjid = xmppipe_mucjid(state->out, state->resource);
}
else if (!(state->opt & XMPPIPE_OPT_GROUPCHAT)) {
char *from = strchr(jid, '@');
if (from == NULL)
usage(state);
from++;
state->out = xmppipe_conference(state->room, from);
}
if (xmppipe_fmt_init() < 0)
errx(EXIT_FAILURE, "xmppipe_fmt_init");

Loading…
Cancel
Save