aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorRichard M. Stallman1999-01-16 21:45:10 +0000
committerRichard M. Stallman1999-01-16 21:45:10 +0000
commita2b3f2b55c2d4c813e3feb0ddf005dfa6000b9d6 (patch)
treebc7595e3786b9b1c0433b54c26759536570a38d0 /lib-src
parent40beb971f4015cea4252d2f1e7dfb130a8f1ae75 (diff)
downloademacs-a2b3f2b55c2d4c813e3feb0ddf005dfa6000b9d6.tar.gz
emacs-a2b3f2b55c2d4c813e3feb0ddf005dfa6000b9d6.zip
(main): Eliminate arbitrary limit on length of system_name.
(xmalloc): Define unconditionally.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/emacsclient.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 5e95604c4f9..412256b916e 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -146,7 +146,6 @@ quote_file_name (name)
146 return copy; 146 return copy;
147} 147}
148 148
149#ifdef C_ALLOCA
150/* Like malloc but get fatal error if memory is exhausted. */ 149/* Like malloc but get fatal error if memory is exhausted. */
151 150
152char * 151char *
@@ -161,7 +160,6 @@ xmalloc (size)
161 } 160 }
162 return result; 161 return result;
163} 162}
164#endif /* C_ALLOCA */
165 163
166#if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC) 164#if !defined (HAVE_SOCKETS) && !defined (HAVE_SYSVIPC)
167 165
@@ -194,7 +192,8 @@ main (argc, argv)
194 int argc; 192 int argc;
195 char **argv; 193 char **argv;
196{ 194{
197 char system_name[32]; 195 char *system_name;
196 int system_name_length;
198 int s, i; 197 int s, i;
199 FILE *out, *in; 198 FILE *out, *in;
200 struct sockaddr_un server; 199 struct sockaddr_un server;
@@ -223,10 +222,22 @@ main (argc, argv)
223#ifndef SERVER_HOME_DIR 222#ifndef SERVER_HOME_DIR
224 { 223 {
225 struct stat statbfr; 224 struct stat statbfr;
225 system_name_length = 32;
226
227 while (1)
228 {
229 system_name = (char *) xmalloc (system_name_length + 1);
230
231 /* system_name must be null-terminated string. */
232 system_name[system_name_length] = '\0';
233
234 if (gethostname (system_name, system_name_length) == 0)
235 break;
236
237 free (system_name);
238 system_name_length *= 2;
239 }
226 240
227 gethostname (system_name, sizeof (system_name));
228 /* system_name must be null-terminated string */
229 system_name[sizeof (system_name) - 1] = '\0';
230 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name); 241 sprintf (server.sun_path, "/tmp/esrv%d-%s", geteuid (), system_name);
231 242
232 if (stat (server.sun_path, &statbfr) == -1) 243 if (stat (server.sun_path, &statbfr) == -1)