summaryrefslogtreecommitdiff
path: root/usr.sbin/cron/crontab.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-31 03:10:56 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-31 03:10:56 +0000
commit8bfcc1e0f15c60804a15866767f8d7c1b9c1c2e3 (patch)
treea46297bf32963a74b17918e455208f167ec80296 /usr.sbin/cron/crontab.c
parent96b5904fe5a01d27b4f66db2d81815af4102c17c (diff)
Proper strncpy() usage.
Diffstat (limited to 'usr.sbin/cron/crontab.c')
-rw-r--r--usr.sbin/cron/crontab.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c
index ae7d042a60f..561e11edf81 100644
--- a/usr.sbin/cron/crontab.c
+++ b/usr.sbin/cron/crontab.c
@@ -16,7 +16,7 @@
*/
#if !defined(lint) && !defined(LINT)
-static char rcsid[] = "$Id: crontab.c,v 1.4 1996/09/16 17:19:54 millert Exp $";
+static char rcsid[] = "$Id: crontab.c,v 1.5 1996/10/31 03:10:55 millert Exp $";
#endif
/* crontab - install and manage per-user crontab files
@@ -143,7 +143,8 @@ parse_args(argc, argv)
fprintf(stderr, "bailing out.\n");
exit(ERROR_EXIT);
}
- strncpy(User, pw->pw_name, sizeof User);
+ (void) strncpy(User, pw->pw_name, (sizeof User)-1);
+ User[(sizeof User)-1] = '\0';
strcpy(RealUser, User);
Filename[0] = '\0';
Option = opt_unknown;
@@ -166,7 +167,8 @@ parse_args(argc, argv)
ProgramName, optarg);
exit(ERROR_EXIT);
}
- (void) strncpy(User, optarg, sizeof User);
+ (void) strncpy(User, pw->pw_name, (sizeof User)-1);
+ User[(sizeof User)-1] = '\0';
break;
case 'l':
if (Option != opt_unknown)
@@ -197,7 +199,9 @@ parse_args(argc, argv)
} else {
if (argv[optind] != NULL) {
Option = opt_replace;
- (void) strncpy (Filename, argv[optind], sizeof Filename);
+ (void) strncpy (Filename, argv[optind], (sizeof Filename)-1);
+ Filename[(sizeof Filename)-1] = '\0';
+
} else {
usage("file name must be specified for replace");
}