diff options
| -rw-r--r-- | lib-src/emacsclient.c | 2 | ||||
| -rw-r--r-- | lib-src/emacsserver.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 07d446b7aa4..5e95604c4f9 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -225,6 +225,8 @@ main (argc, argv) 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) diff --git a/lib-src/emacsserver.c b/lib-src/emacsserver.c index 3675c8efcaf..ba3fa08476e 100644 --- a/lib-src/emacsserver.c +++ b/lib-src/emacsserver.c @@ -251,6 +251,8 @@ main (argc, argv) 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) |
