add: if (argv[c] == NULL) { if (!whacked) goto bail; } else if (argv[c][0] != '}') { goto bail; }
context: parse_ps(int argc, char **argv, ike_ps_t **presharedpp, int *len){	uint_t		c = 0, locidlen, remidlen, keylen, keybits;	uint_t		a_locidtotal = 0, a_remidtotal = 0;	char		*locid, *remid;	uint8_t		*keyp = NULL;	uint16_t	fldid, locidtype, remidtype, mtype;	struct hostent	*loche = NULL, *remhe = NULL;	ike_ps_t	*psp = NULL;	sadb_ident_t	*sidp;	if ((argv[c] == NULL) || (argv[c][0] != '{'))		return (-1);	if (argv[c][1] != 0) {		/* no space between '{' and first token */		argv[c]++;	} else {		c++;	}	while ((c < argc) && (argv[c] != NULL) && (argv[c][0] != '}')) {		if (parse_psfldid(argv[c++], &fldid) < 0)			goto bail;		switch (fldid) {		case PSFLD_LOCID:			locid = argv[c++];			locidlen = strlen(locid) + 1;			break;		case PSFLD_LOCIDTYPE:			if (parse_idtype(argv[c++], &locidtype) < 0)				goto bail;			break;		case PSFLD_REMID:			remid = argv[c++];			remidlen = strlen(remid) + 1;			break;		case PSFLD_REMIDTYPE:			if (parse_idtype(argv[c++], &remidtype) < 0)				goto bail;			break;		case PSFLD_MODE:			if (parse_ikmtype(argv[c++], &mtype) < 0)				goto bail;			break;		case PSFLD_KEY:			keyp  = parse_key(argv[c++], &keylen, &keybits);			if (keyp == NULL)				goto bail;			break;		}	}	/*	 * make sure we got all the required fields.  If no idtype, assume	 * ip addr; if that translation fails, we'll catch the error then.	 */	if (locid == NULL || remid == NULL || keyp == NULL || mtype == 0)		goto bail;	/* figure out the size buffer we need */	*len = sizeof (ike_ps_t);	if (locidtype != SADB_IDENTTYPE_RESERVED) {		a_locidtotal = IKEDOORROUNDUP(sizeof (sadb_ident_t) + locidlen);		*len += a_locidtotal;	}	if (remidtype != SADB_IDENTTYPE_RESERVED) {		a_remidtotal = IKEDOORROUNDUP(sizeof (sadb_ident_t) + remidlen);		*len += a_remidtotal;	}	*len += keylen;	psp = malloc(*len);	if (psp == NULL)		goto bail;	(void) memset(psp, 0, *len);	psp->ps_ike_mode = mtype;	psp->ps_localid_off = sizeof (ike_ps_t);	if (locidtype == SADB_IDENTTYPE_RESERVED) {		/*		 * this is an ip address, store in the sockaddr field;		 * we won't use an sadb_ident_t.		 */		psp->ps_localid_len = 0;		if (parse_addr(1, &locid, &loche) < 0)			goto bail;		if (loche->h_addr_list[1] != NULL) {			message(gettext("preshared key identifier cannot "			    "match multiple IP addresses"));			goto bail;		}		headdr2sa(loche->h_addr_list[0], &psp->ps_ipaddrs.loc_addr,		    loche->h_length);		FREE_HE(loche);	} else {		psp->ps_localid_len = sizeof (sadb_ident_t) + locidlen;		sidp = (sadb_ident_t *)((int)psp + psp->ps_localid_off);		sidp->sadb_ident_len = psp->ps_localid_len;		sidp->sadb_ident_type = locidtype;		(void) strcpy((char *)(sidp + 1), locid);	}	psp->ps_remoteid_off = psp->ps_localid_off + a_locidtotal;	if (remidtype == SADB_IDENTTYPE_RESERVED) {		/*		 * this is an ip address, store in the sockaddr field;		 * we won't use an sadb_ident_t.		 */		psp->ps_remoteid_len = 0;		if (parse_addr(1, &remid, &remhe) < 0)			goto bail;		if (remhe->h_addr_list[1] != NULL) {			message(gettext("preshared key identifier cannot "			    "match multiple IP addresses"));			goto bail;		}		headdr2sa(remhe->h_addr_list[0], &psp->ps_ipaddrs.rem_addr,		    remhe->h_length);		FREE_HE(remhe);	} else {		/* make sure we have at least 16-bit alignment */		if (remidlen & 0x1)			remidlen++;		psp->ps_remoteid_len = sizeof (sadb_ident_t) + remidlen;		sidp = (sadb_ident_t *)((int)psp + psp->ps_remoteid_off);		sidp->sadb_ident_len = psp->ps_remoteid_len;		sidp->sadb_ident_type = remidtype;		(void) strcpy((char *)(sidp + 1), remid);	}	psp->ps_key_off = psp->ps_remoteid_off + a_remidtotal;	psp->ps_key_len = keylen;	psp->ps_key_bits = keybits;	(void) memcpy((uint8_t *)((int)psp + psp->ps_key_off), keyp, keylen);	*presharedpp = psp;	return (c);bail:	if (loche != NULL)		FREE_HE(loche);	if (remhe != NULL)		FREE_HE(remhe);	if (keyp != NULL)		free(keyp);	if (psp != NULL)		free(psp);	*presharedpp = NULL;	return (-1);}