summaryrefslogtreecommitdiff
path: root/lib/libc/string
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>1999-09-08 22:56:55 +0000
committerlukem <lukem@NetBSD.org>1999-09-08 22:56:55 +0000
commite447fb4bb49fd0f8f19189890b48d55bd198ac4b (patch)
tree60a6a12b9391c4d7674da3ecd8521169b7628c85 /lib/libc/string
parenta10045109d204b54f4cfca18dd782f0e875caf3b (diff)
add netbsd rcsid's
update for knf (return value on separate line to function name...) check dst and src aren't null pointers before trying to use them enable strlcat/strlcpy
Diffstat (limited to 'lib/libc/string')
-rw-r--r--lib/libc/string/Makefile.inc9
-rw-r--r--lib/libc/string/strlcat.c12
-rw-r--r--lib/libc/string/strlcpy.35
-rw-r--r--lib/libc/string/strlcpy.c12
4 files changed, 26 insertions, 12 deletions
diff --git a/lib/libc/string/Makefile.inc b/lib/libc/string/Makefile.inc
index 022f8ab55cb..320cd9601e9 100644
--- a/lib/libc/string/Makefile.inc
+++ b/lib/libc/string/Makefile.inc
@@ -1,10 +1,10 @@
# from: @(#)Makefile.inc 8.1 (Berkeley) 6/4/93
-# $NetBSD: Makefile.inc,v 1.48 1999/02/24 15:05:21 drochner Exp $
+# $NetBSD: Makefile.inc,v 1.49 1999/09/08 22:56:56 lukem Exp $
# string sources
.PATH: ${ARCHDIR}/string ${.CURDIR}/string
-SRCS+= bm.c strcasecmp.c strcoll.c strdup.c strerror.c \
+SRCS+= bm.c strcasecmp.c strcoll.c strdup.c strerror.c strlcat.c strlcpy.c \
strmode.c strsignal.c strtok.c strtok_r.c strxfrm.c \
__strerror.c __strsignal.c
@@ -40,8 +40,8 @@ SRCS+= strrchr.c
MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \
memcmp.3 memcpy.3 memmove.3 memset.3 rindex.3 strcasecmp.3 strcat.3 \
- strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strerror.3 \
- string.3 strlen.3 strmode.3 strdup.3 strpbrk.3 strrchr.3 strsep.3 \
+ strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strdup.3 strerror.3 \
+ string.3 strlcpy.3 strlen.3 strmode.3 strpbrk.3 strrchr.3 strsep.3 \
strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3
MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3
@@ -49,4 +49,5 @@ MLINKS+=strcasecmp.3 strncasecmp.3
MLINKS+=strcat.3 strncat.3
MLINKS+=strcmp.3 strncmp.3
MLINKS+=strcpy.3 strncpy.3
+MLINKS+=strlcpy.3 strlcat.3
MLINKS+=strtok.3 strtok_r.3
diff --git a/lib/libc/string/strlcat.c b/lib/libc/string/strlcat.c
index 599994edf5a..57566ead987 100644
--- a/lib/libc/string/strlcat.c
+++ b/lib/libc/string/strlcat.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $ */
+/* $NetBSD: strlcat.c,v 1.2 1999/09/08 22:56:55 lukem Exp $ */
+/* from OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -27,8 +28,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $";
+__RCSID("$NetBSD: strlcat.c,v 1.2 1999/09/08 22:56:55 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -40,7 +42,8 @@ static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
-size_t strlcat(dst, src, siz)
+size_t
+strlcat(dst, src, siz)
char *dst;
const char *src;
size_t siz;
@@ -50,6 +53,9 @@ size_t strlcat(dst, src, siz)
register size_t n = siz;
size_t dlen;
+ if (dst == NULL || src == NULL)
+ return (0);
+
/* Find the end of dst and adjust bytes left but don't go past end */
while (*d != '\0' && n-- != 0)
d++;
diff --git a/lib/libc/string/strlcpy.3 b/lib/libc/string/strlcpy.3
index b07e30e6ea3..a11e9123095 100644
--- a/lib/libc/string/strlcpy.3
+++ b/lib/libc/string/strlcpy.3
@@ -1,4 +1,5 @@
-.\" $OpenBSD: strlcpy.3,v 1.6 1999/09/04 02:22:46 pjanzen Exp $
+.\" $NetBSD: strlcpy.3,v 1.2 1999/09/08 22:56:56 lukem Exp $
+.\" from OpenBSD: strlcpy.3,v 1.6 1999/09/04 02:22:46 pjanzen Exp
.\"
.\" Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
.\" All rights reserved.
@@ -25,7 +26,7 @@
.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 22, 1998
+.Dd September 9, 1999
.Dt STRLCPY 3
.Os
.Sh NAME
diff --git a/lib/libc/string/strlcpy.c b/lib/libc/string/strlcpy.c
index 300a28bc391..fe57f6d3084 100644
--- a/lib/libc/string/strlcpy.c
+++ b/lib/libc/string/strlcpy.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
+/* $NetBSD: strlcpy.c,v 1.2 1999/09/08 22:56:56 lukem Exp $ */
+/* from OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -27,8 +28,9 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
+__RCSID("$NetBSD: strlcpy.c,v 1.2 1999/09/08 22:56:56 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -39,7 +41,8 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
-size_t strlcpy(dst, src, siz)
+size_t
+strlcpy(dst, src, siz)
char *dst;
const char *src;
size_t siz;
@@ -48,6 +51,9 @@ size_t strlcpy(dst, src, siz)
register const char *s = src;
register size_t n = siz;
+ if (dst == NULL || src == NULL)
+ return (0);
+
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {