diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-04 23:12:03 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2003-04-04 23:12:03 +0000 |
commit | 89818c6c69a0745284f6b5368cadd229bfe9c8cb (patch) | |
tree | 08fc92eea8682b34602753108636507bc3c3b03e /bin/ksh/misc.c | |
parent | af21411c6974d6f0daa1fc6bb7e44821b1329bdf (diff) |
two fixes; help from tedu & tdeval
Diffstat (limited to 'bin/ksh/misc.c')
-rw-r--r-- | bin/ksh/misc.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c index d916ec47302..bf0149591bf 100644 --- a/bin/ksh/misc.c +++ b/bin/ksh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.14 2003/03/13 09:03:07 deraadt Exp $ */ +/* $OpenBSD: misc.c,v 1.15 2003/04/04 23:12:02 deraadt Exp $ */ /* * Miscellaneous functions @@ -83,7 +83,17 @@ str_save(s, ap) register const char *s; Area *ap; { - return s ? strcpy((char*) alloc((size_t)strlen(s)+1, ap), s) : NULL; + size_t len; + char *p; + + if (!s) + return NULL; + len = strlen(s)+1; + p = alloc(len, ap); + if (!p) + return NULL; + strlcpy(p, s, len+1); + return (p); } /* Allocate a string of size n+1 and copy upto n characters from the possibly |