/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
* Portions Copyright (c) 2007,2009 by Internet Systems Consortium, Inc. ("ISC")
- * Portions Copyright (c) 2012-2013 by Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (c) 2012-2014 by Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
} else {
char *dp = (char *) malloc(len + 2);
int l;
+ if (dp == NULL) {
+ EREPORT(("malloc() failed for dp\n"));
+ return;
+ }
memcpy(dp, s, len + 1);
l = strlen (dp);
if (dp[l - 1] != '/') {
memset(new_key, 0, sizeof(*new_key));
new_key->dk_key_name = strdup(name);
+ if (new_key->dk_key_name == NULL) {
+ EREPORT(("Unable to duplicate name for key"));
+ free(new_key);
+ return (NULL);
+ }
new_key->dk_alg = alg;
new_key->dk_flags = flags;
new_key->dk_proto = protocol;
if (pk_key->dk_key_name && !strcmp(pk_key->dk_key_name, name))
SAFE_FREE2(pk_key->dk_key_name, strlen(pk_key->dk_key_name));
pk_key->dk_key_name = (char *) strdup(name);
+ if (pk_key->dk_key_name == NULL) {
+ EREPORT(("Unable to duplicate name for key"));
+ goto fail;
+ }
/* allocate and fill in key structure */
if (pk_key->dk_func == NULL || pk_key->dk_func->from_file_fmt == NULL)
f_key->dk_alg));
}
if (f_key->dk_KEY_struct) {
- SAFE_FREE(f_key->dk_KEY_struct);
+ SAFE_FREE2(f_key->dk_KEY_struct, sizeof(f_key->dk_KEY_struct));
}
if (f_key->dk_key_name)
SAFE_FREE(f_key->dk_key_name);
switch (mode) {
case DST_RAND_SEMI:
bp = buff = (u_int32_t *) malloc(wanted+sizeof(u_int32_t));
+ if (bp == NULL) {
+ EREPORT(("malloc() failed for buff in function dst_random\n"));
+ return (0);
+ }
for (i = 0; i < wanted; i+= sizeof(u_int32_t), bp++) {
*bp = dst_s_quick_random(i);
}
/*
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
* Portions Copyright (c) 2007,2009 by Internet Systems Consortium, Inc. ("ISC")
- * Portions Copyright (c) 2012 by Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (c) 2012,2014 by Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
return (-4);
len = eol - p;
tmp = malloc(len + 2);
+ if (tmp == NULL)
+ return (-5);
+
memcpy(tmp, p, len);
*(tmp + len) = 0x0;
key_len = b64_pton((char *)tmp, key, HMAC_LEN+1); /* see above */
len = size > 64 ? 64 : size;
buff = malloc(len+8);
+ if (buff == NULL)
+ return (-1);
n = dst_random(DST_RAND_SEMI, len, buff);
n += dst_random(DST_RAND_KEY, len, buff);
static const char rcsid[] = "$Header: /tmp/cvstest/DHCP/dst/prandom.c,v 1.10 2012/03/09 11:18:13 tomasz Exp $";
#endif
/*
- * Portions Copyright (c) 2012,2013 by Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (c) 2012,2013-2014 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
*
if (hash->step > 1) { /* if using subset of input data */
tmp_size = size / hash->step + 2;
abuf = tp = malloc(tmp_size);
+ /* no good return code but at least don't step on things */
+ if (tp == NULL) {
+ return (0);
+ }
tmp = tp;
for (cnt = 0, i = hash->curr; i < size; i += hash->step, cnt++)
*(tp++) = input[i];