incorrect max login name size
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Sat, 20 Aug 1983 07:19:33 +0000 (23:19 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Sat, 20 Aug 1983 07:19:33 +0000 (23:19 -0800)
SCCS-vsn: usr.bin/lastcomm/lastcomm.c 4.8
SCCS-vsn: usr.sbin/quot/quot.c 4.8
SCCS-vsn: bin/ls/ls.c 4.19
SCCS-vsn: usr.bin/who/who.c 4.6

usr/src/bin/ls/ls.c
usr/src/usr.bin/lastcomm/lastcomm.c
usr/src/usr.bin/who/who.c
usr/src/usr.sbin/quot/quot.c

index 91cadd3..60c9e21 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)ls.c        4.18 (Berkeley) %G%";
+static char *sccsid = "@(#)ls.c        4.19 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -589,10 +589,11 @@ fmtmode(lp, flags)
 #include <utmp.h>
 
 struct utmp utmp;
 #include <utmp.h>
 
 struct utmp utmp;
+#define        NMAX    (sizeof (utmp.ut_name))
+#define SCPYN(a, b)    strncpy(a, b, NMAX)
 
 #define NUID   2048
 #define NGID   300
 
 #define NUID   2048
 #define NGID   300
-#define        NMAX    (sizeof (utmp.ut_name))
 
 char   names[NUID][NMAX+1];
 char   outrangename[NMAX+1];
 
 char   names[NUID][NMAX+1];
 char   outrangename[NMAX+1];
@@ -620,7 +621,7 @@ getname(uid)
                        if (pw->pw_uid != uid)
                                continue;
                        outrangeuid = pw->pw_uid;
                        if (pw->pw_uid != uid)
                                continue;
                        outrangeuid = pw->pw_uid;
-                       strncpy(outrangename, pw->pw_name, NUID);
+                       SCPYN(outrangename, pw->pw_name);
                        endpwent();
                        return (outrangename);
                }
                        endpwent();
                        return (outrangename);
                }
@@ -633,14 +634,14 @@ getname(uid)
                if (pw->pw_uid < 0 || pw->pw_uid >= NUID) {
                        if (pw->pw_uid == uid) {
                                outrangeuid = pw->pw_uid;
                if (pw->pw_uid < 0 || pw->pw_uid >= NUID) {
                        if (pw->pw_uid == uid) {
                                outrangeuid = pw->pw_uid;
-                               strncpy(outrangename, pw->pw_name, NUID);
+                               SCPYN(outrangename, pw->pw_name);
                                return (outrangename);
                        }
                        continue;
                }
                if (names[pw->pw_uid][0])
                        continue;
                                return (outrangename);
                        }
                        continue;
                }
                if (names[pw->pw_uid][0])
                        continue;
-               strncpy(names[pw->pw_uid], pw->pw_name, NMAX);
+               SCPYN(names[pw->pw_uid], pw->pw_name);
                if (pw->pw_uid == uid) {
                        return (&names[uid][0]);
                }
                if (pw->pw_uid == uid) {
                        return (&names[uid][0]);
                }
@@ -669,7 +670,7 @@ getgroup(gid)
                        if (gr->gr_gid != gid)
                                continue;
                        outrangegid = gr->gr_gid;
                        if (gr->gr_gid != gid)
                                continue;
                        outrangegid = gr->gr_gid;
-                       strncpy(outrangegroup, gr->gr_name, NGID);
+                       SCPYN(outrangegroup, gr->gr_name);
                        endgrent();
                        return (outrangegroup);
                }
                        endgrent();
                        return (outrangegroup);
                }
@@ -682,14 +683,14 @@ getgroup(gid)
                if (gr->gr_gid < 0 || gr->gr_gid >= NGID) {
                        if (gr->gr_gid == gid) {
                                outrangegid = gr->gr_gid;
                if (gr->gr_gid < 0 || gr->gr_gid >= NGID) {
                        if (gr->gr_gid == gid) {
                                outrangegid = gr->gr_gid;
-                               strncpy(outrangegroup, gr->gr_name, NGID);
+                               SCPYN(outrangegroup, gr->gr_name);
                                return (outrangegroup);
                        }
                        continue;
                }
                if (groups[gr->gr_gid][0])
                        continue;
                                return (outrangegroup);
                        }
                        continue;
                }
                if (groups[gr->gr_gid][0])
                        continue;
-               strncpy(groups[gr->gr_gid], gr->gr_name, NMAX);
+               SCPYN(groups[gr->gr_gid], gr->gr_name);
                if (gr->gr_gid == gid) {
                        return (&groups[gid][0]);
                }
                if (gr->gr_gid == gid) {
                        return (&groups[gid][0]);
                }
index 0c6c868..48b0e5f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)lastcomm.c  4.7 (Berkeley) %G%";
+static char *sccsid = "@(#)lastcomm.c  4.8 (Berkeley) %G%";
 #endif
 
 /*
 #endif
 
 /*
@@ -146,7 +146,7 @@ getname(uid)
                        if (pw->pw_uid != uid)
                                continue;
                        outrangeuid = pw->pw_uid;
                        if (pw->pw_uid != uid)
                                continue;
                        outrangeuid = pw->pw_uid;
-                       strncpy(outrangename, pw->pw_name, NUID);
+                       strncpy(outrangename, pw->pw_name, NMAX);
                        endpwent();
                        return (outrangename);
                }
                        endpwent();
                        return (outrangename);
                }
@@ -159,7 +159,7 @@ getname(uid)
                if (pw->pw_uid < 0 || pw->pw_uid >= NUID) {
                        if (pw->pw_uid == uid) {
                                outrangeuid = pw->pw_uid;
                if (pw->pw_uid < 0 || pw->pw_uid >= NUID) {
                        if (pw->pw_uid == uid) {
                                outrangeuid = pw->pw_uid;
-                               strncpy(outrangename, pw->pw_name, NUID);
+                               strncpy(outrangename, pw->pw_name, NMAX);
                                return (outrangename);
                        }
                        continue;
                                return (outrangename);
                        }
                        continue;
index 7d6df0b..17b7b23 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)who.c       4.5 (Berkeley) %G%";
+static char *sccsid = "@(#)who.c       4.6 (Berkeley) %G%";
 #endif
 /*
  * who
 #endif
 /*
  * who
@@ -39,7 +39,7 @@ main(argc, argv)
                        tp = rindex(tp, '/') + 1;
                else {  /* no tty - use best guess from passwd file */
                        pw = getpwuid(getuid());
                        tp = rindex(tp, '/') + 1;
                else {  /* no tty - use best guess from passwd file */
                        pw = getpwuid(getuid());
-                       strcpy(utmp.ut_name, pw?pw->pw_name: "?");
+                       strncpy(utmp.ut_name, pw ? pw->pw_name : "?", NMAX);
                        strcpy(utmp.ut_line, "tty??");
                        time(&utmp.ut_time);
                        putline();
                        strcpy(utmp.ut_line, "tty??");
                        time(&utmp.ut_time);
                        putline();
index 2c38fa0..47a812f 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)quot.c      4.7 (Berkeley) 83/08/16";
+static char *sccsid = "@(#)quot.c      4.8 (Berkeley) 83/08/19";
 #endif
 
 /*
 #endif
 
 /*
@@ -355,7 +355,7 @@ getname(uid)
                        if (pw->pw_uid != uid)
                                continue;
                        outrangeuid = pw->pw_uid;
                        if (pw->pw_uid != uid)
                                continue;
                        outrangeuid = pw->pw_uid;
-                       strncpy(outrangename, pw->pw_name, NUID);
+                       strncpy(outrangename, pw->pw_name, NMAX);
                        endpwent();
                        return (outrangename);
                }
                        endpwent();
                        return (outrangename);
                }
@@ -368,7 +368,7 @@ getname(uid)
                if (pw->pw_uid < 0 || pw->pw_uid >= NUID) {
                        if (pw->pw_uid == uid) {
                                outrangeuid = pw->pw_uid;
                if (pw->pw_uid < 0 || pw->pw_uid >= NUID) {
                        if (pw->pw_uid == uid) {
                                outrangeuid = pw->pw_uid;
-                               strncpy(outrangename, pw->pw_name, NUID);
+                               strncpy(outrangename, pw->pw_name, NMAX);
                                return (outrangename);
                        }
                        continue;
                                return (outrangename);
                        }
                        continue;