Wed May 20 02:45:17 2015 UTC ()
Pull up following revision(s) (requested by christos in ticket #792):
	crypto/dist/ipsec-tools/src/racoon/gssapi.c: revision 1.5
	crypto/dist/ipsec-tools/src/racoon/gssapi.c: revision 1.6
Protect against a NULL pointer dereference described in:
    https://www.altsci.com/ipsec/
XXX: pullup-7
Detect error earlier to avoid memory leak.
XXX: pullup-7


(msaitoh)
diff -r1.4 -r1.4.66.1 src/crypto/dist/ipsec-tools/src/racoon/gssapi.c

cvs diff -r1.4 -r1.4.66.1 src/crypto/dist/ipsec-tools/src/racoon/gssapi.c (expand / switch to unified diff)

--- src/crypto/dist/ipsec-tools/src/racoon/gssapi.c 2006/09/09 16:22:09 1.4
+++ src/crypto/dist/ipsec-tools/src/racoon/gssapi.c 2015/05/20 02:45:17 1.4.66.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: gssapi.c,v 1.4 2006/09/09 16:22:09 manu Exp $ */ 1/* $NetBSD: gssapi.c,v 1.4.66.1 2015/05/20 02:45:17 msaitoh Exp $ */
2 2
3/* $KAME: gssapi.c,v 1.19 2001/04/03 15:51:55 thorpej Exp $ */ 3/* $KAME: gssapi.c,v 1.19 2001/04/03 15:51:55 thorpej Exp $ */
4 4
5/* 5/*
6 * Copyright 2000 Wasabi Systems, Inc. 6 * Copyright 2000 Wasabi Systems, Inc.
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * This software was written by Frank van der Linden of Wasabi Systems 9 * This software was written by Frank van der Linden of Wasabi Systems
10 * for Zembu Labs, Inc. http://www.zembu.com/ 10 * for Zembu Labs, Inc. http://www.zembu.com/
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -182,26 +182,31 @@ gssapi_get_default_name(struct ph1handle @@ -182,26 +182,31 @@ gssapi_get_default_name(struct ph1handle
182 182
183 return 0; 183 return 0;
184} 184}
185 185
186static int 186static int
187gssapi_init(struct ph1handle *iph1) 187gssapi_init(struct ph1handle *iph1)
188{ 188{
189 struct gssapi_ph1_state *gps; 189 struct gssapi_ph1_state *gps;
190 gss_buffer_desc id_token, cred_token; 190 gss_buffer_desc id_token, cred_token;
191 gss_buffer_t cred = &cred_token; 191 gss_buffer_t cred = &cred_token;
192 gss_name_t princ, canon_princ; 192 gss_name_t princ, canon_princ;
193 OM_uint32 maj_stat, min_stat; 193 OM_uint32 maj_stat, min_stat;
194 194
 195 if (iph1->rmconf == NULL) {
 196 plog(LLV_ERROR, LOCATION, NULL, "no remote config\n");
 197 return -1;
 198 }
 199
195 gps = racoon_calloc(1, sizeof (struct gssapi_ph1_state)); 200 gps = racoon_calloc(1, sizeof (struct gssapi_ph1_state));
196 if (gps == NULL) { 201 if (gps == NULL) {
197 plog(LLV_ERROR, LOCATION, NULL, "racoon_calloc failed\n"); 202 plog(LLV_ERROR, LOCATION, NULL, "racoon_calloc failed\n");
198 return -1; 203 return -1;
199 } 204 }
200 gps->gss_context = GSS_C_NO_CONTEXT; 205 gps->gss_context = GSS_C_NO_CONTEXT;
201 gps->gss_cred = GSS_C_NO_CREDENTIAL; 206 gps->gss_cred = GSS_C_NO_CREDENTIAL;
202 207
203 gssapi_set_state(iph1, gps); 208 gssapi_set_state(iph1, gps);
204 209
205 if (iph1->rmconf->proposal->gssid != NULL) { 210 if (iph1->rmconf->proposal->gssid != NULL) {
206 id_token.length = iph1->rmconf->proposal->gssid->l; 211 id_token.length = iph1->rmconf->proposal->gssid->l;
207 id_token.value = iph1->rmconf->proposal->gssid->v; 212 id_token.value = iph1->rmconf->proposal->gssid->v;