use bounded string op and strdup
This commit is contained in:
parent
cad152ee49
commit
ac9d94f21a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: getcap.c,v 1.4 2002/02/02 15:08:06 lukem Exp $ */
|
||||
/* $NetBSD: getcap.c,v 1.5 2003/08/06 13:43:31 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -46,7 +46,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: getcap.c,v 1.4 2002/02/02 15:08:06 lukem Exp $");
|
||||
__RCSID("$NetBSD: getcap.c,v 1.5 2003/08/06 13:43:31 itojun Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
|
@ -117,12 +117,12 @@ cgetset(const char *ent)
|
|||
return (0);
|
||||
}
|
||||
topreclen = strlen(ent);
|
||||
if ((toprec = malloc (topreclen + 1)) == NULL) {
|
||||
toprec = strdup(ent);
|
||||
if (toprec == NULL) {
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
gottoprec = 0;
|
||||
(void)strcpy(toprec, ent); /* XXX: strcpy is safe */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ getent(char **cap, size_t *len, char **db_array, int fd, const char *name,
|
|||
* Check if we have a top record from cgetset().
|
||||
*/
|
||||
if (depth == 0 && toprec != NULL && cgetmatch(toprec, name) == 0) {
|
||||
if ((record = malloc (topreclen + BFRAG)) == NULL) {
|
||||
if ((record = malloc(topreclen + BFRAG)) == NULL) {
|
||||
errno = ENOMEM;
|
||||
return (-2);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: yplib.c,v 1.3 1999/09/19 19:51:11 christos Exp $ */
|
||||
/* $NetBSD: yplib.c,v 1.4 2003/08/06 13:43:32 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
||||
|
@ -266,7 +266,7 @@ yperr_string(incode)
|
|||
if (incode == 0)
|
||||
return "Success";
|
||||
|
||||
sprintf(err, "YP FAKE error %d\n", incode);
|
||||
snprintf(err, sizeof(err), "YP FAKE error %d\n", incode);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue