summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2008-04-30 23:18:21 +0000
committerKen Raeburn <raeburn@mit.edu>2008-04-30 23:18:21 +0000
commitec5b9670de4c7af9ebaecfbd305857ee030460c0 (patch)
treef6bf89e559978a8cea0ee428421ab75dba969381 /src/lib
parent4fe69e66b424f10e6a44f8bd488e3fa56682edbf (diff)
After malloc/realloc/calloc failures, return ENOMEM explicitly instead
of reading it from errno. This may make static analysis tools less confused about when we return zero vs nonzero values. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20312 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/crypto/des/string2key.c4
-rw-r--r--src/lib/crypto/dk/dk_encrypt.c2
-rw-r--r--src/lib/crypto/pbkdf2.c6
-rw-r--r--src/lib/kadm5/alt_prof.c4
-rw-r--r--src/lib/kadm5/srv/server_dict.c4
-rw-r--r--src/lib/krb5/ccache/cc_memory.c4
-rw-r--r--src/lib/krb5/os/hostaddr.c4
-rw-r--r--src/lib/krb5/os/init_os_ctx.c4
-rw-r--r--src/lib/krb5/os/localaddr.c6
-rw-r--r--src/lib/krb5/os/locate_kdc.c4
10 files changed, 21 insertions, 21 deletions
diff --git a/src/lib/crypto/des/string2key.c b/src/lib/crypto/des/string2key.c
index 4fe9e4799a..016ae3e201 100644
--- a/src/lib/crypto/des/string2key.c
+++ b/src/lib/crypto/des/string2key.c
@@ -1,7 +1,7 @@
/*
* lib/crypto/des/des_s2k.c
*
- * Copyright 2004 by the Massachusetts Institute of Technology.
+ * Copyright 2004, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -84,7 +84,7 @@ mit_des_string_to_key_int (krb5_keyblock *key,
a byte array, not a string. */
copy = malloc(copylen);
if (copy == NULL)
- return errno;
+ return ENOMEM;
memcpy(copy, pw->data, pw->length);
if (salt)
memcpy(copy + pw->length, salt->data, salt->length);
diff --git a/src/lib/crypto/dk/dk_encrypt.c b/src/lib/crypto/dk/dk_encrypt.c
index 5b2d3e7937..750f43ffed 100644
--- a/src/lib/crypto/dk/dk_encrypt.c
+++ b/src/lib/crypto/dk/dk_encrypt.c
@@ -205,7 +205,7 @@ trunc_hmac (const struct krb5_hash_provider *hash,
tmp.length = hashsize;
tmp.data = malloc(hashsize);
if (tmp.data == NULL)
- return errno;
+ return ENOMEM;
ret = krb5_hmac(hash, ki, num, input, &tmp);
if (ret == 0)
memcpy(output->data, tmp.data, output->length);
diff --git a/src/lib/crypto/pbkdf2.c b/src/lib/crypto/pbkdf2.c
index ff446dbde7..a6cce1cd0f 100644
--- a/src/lib/crypto/pbkdf2.c
+++ b/src/lib/crypto/pbkdf2.c
@@ -1,7 +1,7 @@
/*
* lib/crypto/pbkdf2.c
*
- * Copyright 2002 by the Massachusetts Institute of Technology.
+ * Copyright 2002, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -171,11 +171,11 @@ krb5int_pbkdf2 (krb5_error_code (*prf)(krb5_keyblock *, krb5_data *,
utmp1 = /*output + dklen; */ malloc(hlen);
if (utmp1 == NULL)
- return errno;
+ return ENOMEM;
utmp2 = /*utmp1 + hlen; */ malloc(salt->length + 4 + hlen);
if (utmp2 == NULL) {
free(utmp1);
- return errno;
+ return ENOMEM;
}
/* Step 3. */
diff --git a/src/lib/kadm5/alt_prof.c b/src/lib/kadm5/alt_prof.c
index 6802090d56..5724c14031 100644
--- a/src/lib/kadm5/alt_prof.c
+++ b/src/lib/kadm5/alt_prof.c
@@ -1,7 +1,7 @@
/*
* lib/kadm/alt_prof.c
*
- * Copyright 1995,2001 by the Massachusetts Institute of Technology.
+ * Copyright 1995,2001,2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -91,7 +91,7 @@ krb5_aprof_init(fname, envname, acontextp)
profile_path = malloc(2 + krb5_config_len + kdc_config_len);
if (profile_path == NULL) {
krb5_free_config_files(filenames);
- return errno;
+ return ENOMEM;
}
if (kdc_config_len)
strcpy(profile_path, kdc_config);
diff --git a/src/lib/kadm5/srv/server_dict.c b/src/lib/kadm5/srv/server_dict.c
index 4f41b0d414..ece7831c90 100644
--- a/src/lib/kadm5/srv/server_dict.c
+++ b/src/lib/kadm5/srv/server_dict.c
@@ -108,7 +108,7 @@ int init_dict(kadm5_config_params *params)
return errno;
}
if ((word_block = (char *) malloc(sb.st_size + 1)) == NULL)
- return errno;
+ return ENOMEM;
if (read(fd, word_block, sb.st_size) != sb.st_size)
return errno;
(void) close(fd);
@@ -123,7 +123,7 @@ int init_dict(kadm5_config_params *params)
word_count++;
}
if ((word_list = (char **) malloc(word_count * sizeof(char *))) == NULL)
- return errno;
+ return ENOMEM;
p = word_block;
for (i = 0; i < word_count; i++) {
word_list[i] = p;
diff --git a/src/lib/krb5/ccache/cc_memory.c b/src/lib/krb5/ccache/cc_memory.c
index 173d0039d6..d5c0493baf 100644
--- a/src/lib/krb5/ccache/cc_memory.c
+++ b/src/lib/krb5/ccache/cc_memory.c
@@ -1,7 +1,7 @@
/*
* lib/krb5/ccache/cc_memory.c
*
- * Copyright 1990,1991,2000,2004 by the Massachusetts Institute of Technology.
+ * Copyright 1990,1991,2000,2004,2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -614,7 +614,7 @@ krb5_mcc_store(krb5_context ctx, krb5_ccache id, krb5_creds *creds)
new_node = malloc(sizeof(krb5_mcc_link));
if (new_node == NULL)
- return errno;
+ return ENOMEM;
err = krb5_copy_creds(ctx, creds, &new_node->creds);
if (err) {
free(new_node);
diff --git a/src/lib/krb5/os/hostaddr.c b/src/lib/krb5/os/hostaddr.c
index 76eb1273dc..eaef098588 100644
--- a/src/lib/krb5/os/hostaddr.c
+++ b/src/lib/krb5/os/hostaddr.c
@@ -1,7 +1,7 @@
/*
* lib/krb5/os/hostaddr.c
*
- * Copyright 1990,1991 by the Massachusetts Institute of Technology.
+ * Copyright 1990,1991,2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -73,7 +73,7 @@ krb5_os_hostaddr(krb5_context context, const char *name, krb5_address ***ret_add
addrs = malloc ((i+1) * sizeof(*addrs));
if (!addrs)
- return errno;
+ return ENOMEM;
for (j = 0; j < i + 1; j++)
addrs[j] = 0;
diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c
index 16ff0435f7..132816d059 100644
--- a/src/lib/krb5/os/init_os_ctx.c
+++ b/src/lib/krb5/os/init_os_ctx.c
@@ -1,7 +1,7 @@
/*
* lib/krb5/os/init_ctx.c
*
- * Copyright 1994, 2007 by the Massachusetts Institute of Technology.
+ * Copyright 1994, 2007, 2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -305,7 +305,7 @@ add_kdc_config_file(profile_filespec_t **pfiles)
count += 2;
newfiles = malloc(count * sizeof(*newfiles));
if (newfiles == NULL)
- return errno;
+ return ENOMEM;
memcpy(newfiles + 1, *pfiles, (count-1) * sizeof(*newfiles));
newfiles[0] = strdup(file);
if (newfiles[0] == NULL) {
diff --git a/src/lib/krb5/os/localaddr.c b/src/lib/krb5/os/localaddr.c
index e139ca4d30..ea8c9a2051 100644
--- a/src/lib/krb5/os/localaddr.c
+++ b/src/lib/krb5/os/localaddr.c
@@ -1,7 +1,7 @@
/*
* lib/krb5/os/localaddr.c
*
- * Copyright 1990,1991,2000,2001,2002,2004,2007 by the Massachusetts Institute of Technology.
+ * Copyright 1990,1991,2000,2001,2002,2004,2007,2008 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -873,7 +873,7 @@ get_ifreq_array(char **bufp, size_t *np, int s)
current_buf_size = est_ifreq_size * est_if_count + SLOP;
buf = malloc (current_buf_size);
if (buf == NULL)
- return errno;
+ return ENOMEM;
ask_again:
size = current_buf_size;
@@ -905,7 +905,7 @@ ask_again:
new_size = est_ifreq_size * est_if_count + SLOP;
buf = grow_or_free (buf, new_size);
if (buf == 0)
- return errno;
+ return ENOMEM;
current_buf_size = new_size;
goto ask_again;
}
diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c
index 7605328aee..aedb14a888 100644
--- a/src/lib/krb5/os/locate_kdc.c
+++ b/src/lib/krb5/os/locate_kdc.c
@@ -1,7 +1,7 @@
/*
* lib/krb5/os/locate_kdc.c
*
- * Copyright 1990,2000,2001,2002,2003,2004,2006 Massachusetts Institute of Technology.
+ * Copyright 1990,2000,2001,2002,2003,2004,2006,2008 Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -110,7 +110,7 @@ krb5int_grow_addrlist (struct addrlist *lp, int nmore)
newaddrs = realloc (lp->addrs, newsize);
if (newaddrs == NULL)
- return errno;
+ return ENOMEM;
lp->addrs = newaddrs;
for (i = lp->space; i < newspace; i++) {
lp->addrs[i].ai = NULL;