summaryrefslogtreecommitdiffstats
path: root/login-utils/agetty.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:49 +0100
committerKarel Zak2006-12-07 00:25:49 +0100
commite8f2641919de90b488ce3788a7795b88311750b5 (patch)
tree68f3732da38ff1b21ec49780d7c830250329fec9 /login-utils/agetty.c
parentImported from util-linux-2.11f tarball. (diff)
downloadkernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.tar.gz
kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.tar.xz
kernel-qcow2-util-linux-e8f2641919de90b488ce3788a7795b88311750b5.zip
Imported from util-linux-2.11m tarball.
Diffstat (limited to 'login-utils/agetty.c')
-rw-r--r--login-utils/agetty.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/login-utils/agetty.c b/login-utils/agetty.c
index c7f0f3d26..d53811b2a 100644
--- a/login-utils/agetty.c
+++ b/login-utils/agetty.c
@@ -30,6 +30,7 @@
#include <getopt.h>
#include <time.h>
#include <sys/file.h>
+#include "xstrncpy.h"
#include "nls.h"
#ifdef __linux__
@@ -273,9 +274,14 @@ main(argc, argv)
/* The BSD-style init command passes us a useless process name. */
#ifdef SYSV_STYLE
- progname = argv[0];
+ {
+ char *ptr;
+ progname = argv[0];
+ if ((ptr = strrchr(argv[0], '/')))
+ progname = ++ptr;
+ }
#else
- progname = "agetty";
+ progname = "agetty";
#endif
#ifdef DEBUGGING
@@ -1220,13 +1226,13 @@ error(const char *fmt, ...) {
*/
va_start(ap, fmt);
- while (*fmt) {
+ while (*fmt && bp < &buf[BUFSIZ-1]) {
if (strncmp(fmt, "%s", 2) == 0) {
- (void) strcpy(bp, va_arg(ap, char *));
+ xstrncpy(bp, va_arg(ap, char *), &buf[BUFSIZ-1] - bp);
bp += strlen(bp);
fmt += 2;
} else if (strncmp(fmt, "%m", 2) == 0) {
- (void) strcpy(bp, strerror(errno));
+ xstrncpy(bp, strerror(errno), &buf[BUFSIZ-1] - bp);
bp += strlen(bp);
fmt += 2;
} else {