Commit f035d9ce f035d9ce8e917fbd2d9f8b8d2317dbbe868df165 by Sergey Poznyakoff

(auth_gssapi): Check return codes from gss_wrap, gss_unwrap.

1 parent 5c39e227
...@@ -190,8 +190,14 @@ auth_gssapi (struct imap4d_command *command, ...@@ -190,8 +190,14 @@ auth_gssapi (struct imap4d_command *command,
190 sec_level = htonl ((SUPPORTED_P_MECH << 24) | server_buffer_size); 190 sec_level = htonl ((SUPPORTED_P_MECH << 24) | server_buffer_size);
191 tokbuf.length = 4; 191 tokbuf.length = 4;
192 tokbuf.value = &sec_level; 192 tokbuf.value = &sec_level;
193 gss_wrap (&min_stat, context, 0, GSS_C_QOP_DEFAULT, 193 maj_stat = gss_wrap (&min_stat, context, 0, GSS_C_QOP_DEFAULT,
194 &tokbuf, &cflags, &outbuf); 194 &tokbuf, &cflags, &outbuf);
195 if (maj_stat != GSS_S_COMPLETE)
196 {
197 display_status ("wrap", maj_stat, min_stat);
198 return RESP_NO;
199 }
200
195 util_base64_encode (outbuf.value, outbuf.length, &tmp, &size); 201 util_base64_encode (outbuf.value, outbuf.length, &tmp, &size);
196 util_send ("+ %*.*s\r\n", size, size, tmp); 202 util_send ("+ %*.*s\r\n", size, size, tmp);
197 free (tmp); 203 free (tmp);
...@@ -201,9 +207,15 @@ auth_gssapi (struct imap4d_command *command, ...@@ -201,9 +207,15 @@ auth_gssapi (struct imap4d_command *command,
201 (unsigned char **) &tokbuf.value, &tokbuf.length); 207 (unsigned char **) &tokbuf.value, &tokbuf.length);
202 free (token_str); 208 free (token_str);
203 209
204 gss_unwrap (&min_stat, context, &tokbuf, &outbuf, &cflags, &quality); 210 maj_stat = gss_unwrap (&min_stat, context, &tokbuf, &outbuf, &cflags,
211 &quality);
205 free (tokbuf.value); 212 free (tokbuf.value);
206 213 if (maj_stat != GSS_S_COMPLETE)
214 {
215 display_status ("unwrap", maj_stat, min_stat);
216 return RESP_NO;
217 }
218
207 sec_level = ntohl (*(OM_uint32 *) outbuf.value); 219 sec_level = ntohl (*(OM_uint32 *) outbuf.value);
208 220
209 /* FIXME: parse sec_level and act accordingly to its settings */ 221 /* FIXME: parse sec_level and act accordingly to its settings */
......