diff options
author | defanor <defanor@uberspace.net> | 2021-02-11 12:53:29 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2021-02-11 12:53:29 +0300 |
commit | 6acda7ad1f834016c9cebea0dd82467db86baeeb (patch) | |
tree | fe02ac773add7d99d7b5b467afb0f45b4b43efdb | |
parent | 7213096842fdfe1879f26c68030ce8374277c2b6 (diff) |
Add stricter checks for '/' and '@' positions in JIDs
-rw-r--r-- | src/rexmpp_jid.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/rexmpp_jid.c b/src/rexmpp_jid.c index 44e2754..f19bd7c 100644 --- a/src/rexmpp_jid.c +++ b/src/rexmpp_jid.c @@ -21,11 +21,19 @@ int rexmpp_jid_parse (const char *str, struct rexmpp_jid *jid) { /* Find the separators. */ for (i = 0; i < full_len; i++) { if (local_len == 0 && str[i] == '@') { + if (i == 0) { + /* '@' is in the very beginning, an error. */ + return -1; + } local_len = i; domain_len -= local_len + 1; domain = str + i + 1; } if (str[i] == '/') { + if (i == full_len - 1) { + /* '/' is in the end, that's an error. */ + return -1; + } resource_len = full_len - i - 1; domain_len -= resource_len + 1; bare_len -= resource_len + 1; |