changeset 23412:2ce0e36402ff

(main): Null-terminate system_name.
author Richard M. Stallman <rms@gnu.org>
date Sat, 10 Oct 1998 21:20:22 +0000
parents 879b88bb7ab2
children 2a5d56cc4e41
files lib-src/emacsclient.c lib-src/emacsserver.c
diffstat 2 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/emacsclient.c	Sat Oct 10 15:07:08 1998 +0000
+++ b/lib-src/emacsclient.c	Sat Oct 10 21:20:22 1998 +0000
@@ -225,6 +225,8 @@
     struct stat statbfr;
 
     gethostname (system_name, sizeof (system_name));
+    /* system_name must be null-terminated string */
+    system_name[sizeof (system_name) - 1] = '\0';
     sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
 
     if (stat (server.sun_path, &statbfr) == -1)
--- a/lib-src/emacsserver.c	Sat Oct 10 15:07:08 1998 +0000
+++ b/lib-src/emacsserver.c	Sat Oct 10 21:20:22 1998 +0000
@@ -251,6 +251,8 @@
   server.sun_family = AF_UNIX;
 #ifndef SERVER_HOME_DIR
   gethostname (system_name, sizeof (system_name));
+    /* system_name must be null-terminated string */
+    system_name[sizeof (system_name) - 1] = '\0';
   sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
 
   if (unlink (server.sun_path) == -1 && errno != ENOENT)