summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-02-10 23:34:54 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-02-10 23:34:54 +0000
commita905ecd994ad19a733538bb2093d919e85923b98 (patch)
tree8c935684640f19fa529eb258b293253c2faa1a67
parent70ea46a382befd3100020b135d5ff440c51c3bd5 (diff)
- deraadt 2001/02/07 8:57:26
[xmalloc.c] deal with new ANSI malloc stuff - markus@cvs.openbsd.org 2001/02/07 16:46:08 [xmalloc.c] typo in fatal() - itojun@cvs.openbsd.org 2001/02/07 18:04:50 [xmalloc.c] fix size_t -> int cast (use u_long). markus ok
-rw-r--r--ChangeLog11
-rw-r--r--xmalloc.c19
2 files changed, 24 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a82a701d..fe271d62c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -83,6 +83,15 @@
83 - deraadt@cvs.openbsd.org 2001/02/06 22:07:50 83 - deraadt@cvs.openbsd.org 2001/02/06 22:07:50
84 [sshd_config] 84 [sshd_config]
85 enable sftp-server by default 85 enable sftp-server by default
86 - deraadt 2001/02/07 8:57:26
87 [xmalloc.c]
88 deal with new ANSI malloc stuff
89 - markus@cvs.openbsd.org 2001/02/07 16:46:08
90 [xmalloc.c]
91 typo in fatal()
92 - itojun@cvs.openbsd.org 2001/02/07 18:04:50
93 [xmalloc.c]
94 fix size_t -> int cast (use u_long). markus ok
86 - (bal) fixed sftp-client.c. Return 'status' instead of '0' 95 - (bal) fixed sftp-client.c. Return 'status' instead of '0'
87 (from the OpenBSD tree) 96 (from the OpenBSD tree)
88 - (bal) Synced ssh.1, ssh-add.1 and sshd.8 w/ OpenBSD 97 - (bal) Synced ssh.1, ssh-add.1 and sshd.8 w/ OpenBSD
@@ -3871,4 +3880,4 @@
3871 - Wrote replacements for strlcpy and mkdtemp 3880 - Wrote replacements for strlcpy and mkdtemp
3872 - Released 1.0pre1 3881 - Released 1.0pre1
3873 3882
3874$Id: ChangeLog,v 1.735 2001/02/10 23:30:16 mouring Exp $ 3883$Id: ChangeLog,v 1.736 2001/02/10 23:34:54 mouring Exp $
diff --git a/xmalloc.c b/xmalloc.c
index 1a471889a..8a23b8b70 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -13,7 +13,7 @@
13 */ 13 */
14 14
15#include "includes.h" 15#include "includes.h"
16RCSID("$OpenBSD: xmalloc.c,v 1.11 2001/02/04 15:32:27 stevesk Exp $"); 16RCSID("$OpenBSD: xmalloc.c,v 1.14 2001/02/07 18:04:50 itojun Exp $");
17 17
18#include "xmalloc.h" 18#include "xmalloc.h"
19#include "log.h" 19#include "log.h"
@@ -21,9 +21,13 @@ RCSID("$OpenBSD: xmalloc.c,v 1.11 2001/02/04 15:32:27 stevesk Exp $");
21void * 21void *
22xmalloc(size_t size) 22xmalloc(size_t size)
23{ 23{
24 void *ptr = malloc(size); 24 void *ptr;
25
26 if (size == 0)
27 fatal("xmalloc: zero size");
28 ptr = malloc(size);
25 if (ptr == NULL) 29 if (ptr == NULL)
26 fatal("xmalloc: out of memory (allocating %d bytes)", (int) size); 30 fatal("xmalloc: out of memory (allocating %lu bytes)", (u_long) size);
27 return ptr; 31 return ptr;
28} 32}
29 33
@@ -32,11 +36,13 @@ xrealloc(void *ptr, size_t new_size)
32{ 36{
33 void *new_ptr; 37 void *new_ptr;
34 38
39 if (new_size == 0)
40 fatal("xrealloc: zero size");
35 if (ptr == NULL) 41 if (ptr == NULL)
36 fatal("xrealloc: NULL pointer given as argument"); 42 fatal("xrealloc: NULL pointer given as argument");
37 new_ptr = realloc(ptr, new_size); 43 new_ptr = realloc(ptr, new_size);
38 if (new_ptr == NULL) 44 if (new_ptr == NULL)
39 fatal("xrealloc: out of memory (new_size %d bytes)", (int) new_size); 45 fatal("xrealloc: out of memory (new_size %lu bytes)", (u_long) new_size);
40 return new_ptr; 46 return new_ptr;
41} 47}
42 48
@@ -52,8 +58,11 @@ char *
52xstrdup(const char *str) 58xstrdup(const char *str)
53{ 59{
54 size_t len = strlen(str) + 1; 60 size_t len = strlen(str) + 1;
61 char *cp;
55 62
56 char *cp = xmalloc(len); 63 if (len == 0)
64 fatal("xstrdup: zero size");
65 cp = xmalloc(len);
57 strlcpy(cp, str, len); 66 strlcpy(cp, str, len);
58 return cp; 67 return cp;
59} 68}