This commit was manufactured by cvs2svn to create tag 'FreeBSD-release/1.1'.
[unix-history] / libexec / rpc.rusersd / rusers_proc.c
index c64c78c..ab9d6a0 100644 (file)
@@ -32,7 +32,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char rcsid[] = "$Id: rusers_proc.c,v 1.5 1993/08/02 17:50:46 mycroft Exp $";
+static char rcsid[] = "$Id: rusers_proc.c,v 1.2 1994/03/06 02:07:58 jkh Exp $";
 #endif /* not lint */
 
 #include <signal.h>
 #endif /* not lint */
 
 #include <signal.h>
@@ -78,9 +78,9 @@ static char rcsid[] = "$Id: rusers_proc.c,v 1.5 1993/08/02 17:50:46 mycroft Exp
 #define UT_HOSTSIZE sizeof(((struct utmp *)0)->ut_host)
 #endif
 
 #define UT_HOSTSIZE sizeof(((struct utmp *)0)->ut_host)
 #endif
 
-typedef char ut_line_t[UT_LINESIZE];
-typedef char ut_name_t[UT_NAMESIZE];
-typedef char ut_host_t[UT_HOSTSIZE];
+typedef char ut_line_t[UT_LINESIZE+1];
+typedef char ut_name_t[UT_NAMESIZE+1];
+typedef char ut_host_t[UT_HOSTSIZE+1];
 
 utmpidle utmp_idle[MAXUSERS];
 rutmp old_utmp[MAXUSERS];
 
 utmpidle utmp_idle[MAXUSERS];
 rutmp old_utmp[MAXUSERS];
@@ -218,11 +218,16 @@ do_names_2(int all)
                         utmp_idle[nusers].ui_idle =
                                 getidle(usr.ut_line, usr.ut_host);
                         utmp_idle[nusers].ui_utmp.ut_line = line[nusers];
                         utmp_idle[nusers].ui_idle =
                                 getidle(usr.ut_line, usr.ut_host);
                         utmp_idle[nusers].ui_utmp.ut_line = line[nusers];
-                        strncpy(line[nusers], usr.ut_line, sizeof(line[nusers]));
+                        strncpy(line[nusers], usr.ut_line, UT_LINESIZE);
                         utmp_idle[nusers].ui_utmp.ut_name = name[nusers];
                         utmp_idle[nusers].ui_utmp.ut_name = name[nusers];
-                        strncpy(name[nusers], usr.ut_name, sizeof(name[nusers]));
+                        strncpy(name[nusers], usr.ut_name, UT_NAMESIZE);
                         utmp_idle[nusers].ui_utmp.ut_host = host[nusers];
                         utmp_idle[nusers].ui_utmp.ut_host = host[nusers];
-                        strncpy(host[nusers], usr.ut_host, sizeof(host[nusers]));
+                        strncpy(host[nusers], usr.ut_host, UT_HOSTSIZE);
+                       
+                       /* Make sure entries are NUL terminated */
+                       line[nusers][UT_LINESIZE] = 
+                       name[nusers][UT_NAMESIZE] = 
+                       host[nusers][UT_HOSTSIZE] = '\0';
                         nusers++;
                 }
 
                         nusers++;
                 }