use bounded string op

This commit is contained in:
itojun 2003-07-14 11:54:06 +00:00
parent 347022e133
commit 6d415bc4b0
3 changed files with 18 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cdplay.c,v 1.25 2003/07/14 09:18:22 itojun Exp $ */
/* $NetBSD: cdplay.c,v 1.26 2003/07/14 11:55:56 itojun Exp $ */
/*
* Copyright (c) 1999, 2000, 2001 Andrew Doran.
@ -40,7 +40,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: cdplay.c,v 1.25 2003/07/14 09:18:22 itojun Exp $");
__RCSID("$NetBSD: cdplay.c,v 1.26 2003/07/14 11:55:56 itojun Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -211,7 +211,7 @@ main(int argc, char **argv)
if (p > buf)
*p++ = ' ';
strcpy(p, *argv);
strlcpy(p, *argv, sizeof(buf) - (p - buf));
p += len;
}
*p = '\0';

View File

@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
#if 0
static char sccsid[] = "from: @(#)fsplit.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: fsplit.c,v 1.8 2000/07/03 02:51:16 matt Exp $");
__RCSID("$NetBSD: fsplit.c,v 1.9 2003/07/14 11:59:07 itojun Exp $");
#endif
#endif /* not lint */
@ -95,7 +95,7 @@ int getline __P((void));
void get_name __P((char *, int));
int main __P((int, char **));
int lend __P((void));
int lname __P((char *));
int lname __P((char *, size_t));
char *look __P((char *, char *));
int saveit __P((char *));
int scan_name __P((char *, char *));
@ -165,7 +165,7 @@ main(argc, argv)
if (lend()) /* look for an 'end' statement */
break;
if (nflag == 0) /* if no name yet, try and find one */
nflag = lname(name);
nflag = lname(name, sizeof(name));
}
fclose(ofp);
if (rv == 0) { /* no lines in file, forget the file */
@ -299,8 +299,9 @@ lend()
block datas and main programs. */
int
lname(s)
lname(s, l)
char *s;
size_t l;
{
# define LINESIZE 80
char *ptr, *p;
@ -331,21 +332,21 @@ lname(s)
(ptr = look(line, "function")) != 0 ||
(ptr = functs(line)) != 0) {
if(scan_name(s, ptr)) return(1);
strcpy( s, x);
strlcpy(s, x, l);
} else if((ptr = look(line, "program")) != 0) {
if(scan_name(s, ptr)) return(1);
get_name( mainp, 4);
strcpy( s, mainp);
get_name(mainp, 4);
strlcpy(s, mainp, l);
} else if((ptr = look(line, "blockdata")) != 0) {
if(scan_name(s, ptr)) return(1);
get_name( blkp, 6);
strcpy( s, blkp);
strlcpy(s, blkp, l);
} else if((ptr = functs(line)) != 0) {
if(scan_name(s, ptr)) return(1);
strcpy( s, x);
strlcpy(s, x, l);
} else {
get_name( mainp, 4);
strcpy( s, mainp);
get_name(mainp, 4);
strlcpy(s, mainp, l);
}
return(1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pwd_gensalt.c,v 1.9 2002/11/16 04:41:50 itojun Exp $ */
/* $NetBSD: pwd_gensalt.c,v 1.10 2003/07/14 11:54:06 itojun Exp $ */
/*
* Copyright 1997 Niels Provos <provos@physnet.uni-hamburg.de>
@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pwd_gensalt.c,v 1.9 2002/11/16 04:41:50 itojun Exp $");
__RCSID("$NetBSD: pwd_gensalt.c,v 1.10 2003/07/14 11:54:06 itojun Exp $");
#endif /* not lint */
#include <sys/syslimits.h>
@ -124,7 +124,7 @@ pwd_gensalt(char *salt, int max, struct passwd *pwd, char type)
rounds = 4;
strlcpy(salt, bcrypt_gensalt(rounds), max);
} else {
strcpy(salt, ":");
strlcpy(salt, ":", max);
warnx("Unknown option %s.", now);
}