-/* $NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $ */
+/* $NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $ */
/*-
* Copyright (c) 1989, 1993
#if 0
static char sccsid[] = "@(#)strfile.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: strfile.c,v 1.38 2013/09/19 00:34:00 uwe Exp $");
+__RCSID("$NetBSD: strfile.c,v 1.39 2020/04/29 20:45:05 nia Exp $");
#endif
#endif /* not lint */
#endif /* __NetBSD__ */
int ch;
extern int optind;
extern char *optarg;
+ size_t len;
while ((ch = getopt(argc, argv, "c:iorsx")) != -1)
switch(ch) {
if (*argv) {
Infile = *argv;
- if (*++argv)
- (void) strcpy(Outfile, *argv);
+ if (*++argv) {
+ len = strlen(*argv);
+ if (len >= sizeof(Outfile)) {
+ puts("Bad output filename");
+ usage();
+ }
+ (void) memcpy(Outfile, *argv, len + 1);
+ }
}
if (!Infile) {
puts("No input file name");
usage();
}
if (*Outfile == '\0') {
+ len = strlen(Infile) + sizeof(".dat");
+ if (len > sizeof(Outfile)) {
+ puts("Bad input filename");
+ usage();
+ }
(void) strcpy(Outfile, Infile);
(void) strcat(Outfile, ".dat");
}