diff --git a/c2s/c2s.c b/c2s/c2s.c
index 9a18b79..a5ba507 100644
|
a
|
b
|
|
| 244 | 244 | |
| 245 | 245 | snprintf(resource_buf, 1024, "%.*s", NAD_CDATA_L(nad, elem), NAD_CDATA(nad, elem)); |
| 246 | 246 | /* Put resource into JID */ |
| 247 | | if (jid_reset_components(jid, jid->node, jid->domain, resource_buf) == NULL) { |
| | 247 | if (jid == NULL || jid_reset_components(jid, jid->node, jid->domain, resource_buf) == NULL) { |
| 248 | 248 | log_debug(ZONE, "invalid jid data"); |
| 249 | 249 | sx_nad_write(sess->s, stanza_error(nad, 0, stanza_err_BAD_REQUEST)); |
| 250 | 250 | |
diff --git a/sx/sasl_gsasl.c b/sx/sasl_gsasl.c
index ba4aaa6..c793ba0 100644
|
a
|
b
|
|
| 152 | 152 | |
| 153 | 153 | /** move the stream to the auth state */ |
| 154 | 154 | void _sx_sasl_open(sx_t s, Gsasl_session *sd) { |
| 155 | | char *method, *authzid = NULL; |
| | 155 | char *method, *authzid, *realm = NULL; |
| 156 | 156 | struct sx_sasl_creds_st creds = {NULL, NULL, NULL, NULL}; |
| 157 | 157 | _sx_sasl_t ctx = gsasl_session_hook_get(sd); |
| 158 | 158 | |
| … |
… |
|
| 173 | 173 | } |
| 174 | 174 | } else { |
| 175 | 175 | /* override unchecked arbitrary authzid */ |
| 176 | | if(creds.realm) { |
| 177 | | authzid = (char *) malloc(sizeof(char) * (strlen(creds.authnid) + strlen(creds.realm) + 2)); |
| 178 | | sprintf(authzid, "%s@%s", creds.authnid, creds.realm); |
| 179 | | creds.authzid = authzid; |
| | 176 | if(creds.realm && creds.realm[0] != '\0') { |
| | 177 | realm = creds.realm; |
| 180 | 178 | } else { |
| 181 | | creds.authzid = creds.authnid; |
| | 179 | realm = s->req_to; |
| 182 | 180 | } |
| | 181 | authzid = (char *) malloc(sizeof(char) * (strlen(creds.authnid) + strlen(realm) + 2)); |
| | 182 | sprintf(authzid, "%s@%s", creds.authnid, realm); |
| | 183 | creds.authzid = authzid; |
| 183 | 184 | } |
| 184 | 185 | |
| 185 | 186 | /* proceed stream to authenticated state */ |