about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2002-08-22 12:08:06 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2002-08-22 12:08:06 +0000
commit1c5d5bb1f4a2552364d96acfd5c9f6dbd25aaa80 (patch)
treed6ce7977ac7543a6fce2c70f91c5e4c32ac5467c
parent29ff4ab0e294eddae6f3f513be5467b48aa0975e (diff)
downloadzsh-1c5d5bb1f4a2552364d96acfd5c9f6dbd25aaa80.tar.gz
zsh-1c5d5bb1f4a2552364d96acfd5c9f6dbd25aaa80.tar.xz
zsh-1c5d5bb1f4a2552364d96acfd5c9f6dbd25aaa80.zip
17570: tweaks to socket module
-rw-r--r--ChangeLog7
-rw-r--r--Doc/Makefile.in3
-rw-r--r--Doc/Zsh/mod_socket.yo1
-rw-r--r--Src/Modules/socket.c25
4 files changed, 23 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index d42be3345..b6e7d5d6b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2002-08-22  Peter Stephenson  <pws@csr.com>
+
+	* 17570: Src/Modules/socket.c, Doc/Zsh/Makefile.in,
+	Doc/Zsh/mod_socket.yo:  Don't use predefined name `sun'; set
+	length parameter for accept(); fix inclusion of socket module
+	in documentation.
+
 2002-08-20  Sven Wischnowsky  <wischnow@zsh.org>
 
 	* 17569: Src/Zle/zle_tricky.c: fix typo in comment
diff --git a/Doc/Makefile.in b/Doc/Makefile.in
index 5996d332a..7ed9d02d4 100644
--- a/Doc/Makefile.in
+++ b/Doc/Makefile.in
@@ -59,7 +59,8 @@ Zsh/mod_compctl.yo Zsh/mod_complete.yo Zsh/mod_complist.yo \
 Zsh/mod_computil.yo \
 Zsh/mod_deltochar.yo Zsh/mod_example.yo Zsh/mod_files.yo \
 Zsh/mod_mapfile.yo Zsh/mod_mathfunc.yo Zsh/mod_parameter.yo Zsh/mod_pcre.yo \
-Zsh/mod_sched.yo Zsh/mod_stat.yo Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
+Zsh/mod_sched.yo Zsh/mod_socket.yo \
+Zsh/mod_stat.yo Zsh/mod_termcap.yo Zsh/mod_terminfo.yo \
 Zsh/mod_zftp.yo Zsh/mod_zle.yo Zsh/mod_zleparameter.yo \
 Zsh/mod_zprof.yo Zsh/mod_zpty.yo Zsh/mod_zselect.yo \
 Zsh/mod_zutil.yo Zsh/mod_tcp.yo
diff --git a/Doc/Zsh/mod_socket.yo b/Doc/Zsh/mod_socket.yo
index 9c503ffe5..3538c85cd 100644
--- a/Doc/Zsh/mod_socket.yo
+++ b/Doc/Zsh/mod_socket.yo
@@ -62,3 +62,4 @@ it will wait for one.
 In order to elicit more verbose output, use tt(-v).
 )
 enditem()
+)
diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c
index 68e895e68..b676e2d36 100644
--- a/Src/Modules/socket.c
+++ b/Src/Modules/socket.c
@@ -63,7 +63,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
     int err=1, verbose=0, test=0, targetfd=0;
     SOCKLEN_T len;
     char **dargs;
-    struct sockaddr_un sun;
+    struct sockaddr_un soun;
     int sfd;
 
     if (ops['v'])
@@ -101,12 +101,12 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
 	    return 1;
 	}
 
-	sun.sun_family = AF_UNIX;
-	strncpy(sun.sun_path, localfn, UNIX_PATH_MAX);
+	soun.sun_family = AF_UNIX;
+	strncpy(soun.sun_path, localfn, UNIX_PATH_MAX);
 
-	if (bind(sfd, (struct sockaddr *)&sun, sizeof(struct sockaddr_un)))
+	if (bind(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))
 	{
-	    zwarnnam(nam, "could not bind to %s: %e", sun.sun_path, errno);
+	    zwarnnam(nam, "could not bind to %s: %e", soun.sun_path, errno);
 	    close(sfd);
 	    return 1;
 	}
@@ -130,7 +130,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
 	setiparam("REPLY", sfd);
 
 	if (verbose)
-	    printf("%s listener is on fd %d\n", sun.sun_path, sfd);
+	    printf("%s listener is on fd %d\n", soun.sun_path, sfd);
 
 	return 0;
 
@@ -190,7 +190,8 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
 #endif
 	}
 
-	if ((rfd = accept(lfd, (struct sockaddr *)&sun, &len)) == -1)
+	len = sizeof(soun);
+	if ((rfd = accept(lfd, (struct sockaddr *)&soun, &len)) == -1)
 	{
 	    zwarnnam(nam, "could not accept connection: %e", NULL, errno);
 	    return 1;
@@ -207,7 +208,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
 	setiparam("REPLY", sfd);
 
 	if (verbose)
-	    printf("new connection from %s is on fd %d\n", sun.sun_path, sfd);
+	    printf("new connection from %s is on fd %d\n", soun.sun_path, sfd);
     }
     else
     {
@@ -223,10 +224,10 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
 	    return 1;
 	}
 
-	sun.sun_family = AF_UNIX;
-	strncpy(sun.sun_path, dargs[0], UNIX_PATH_MAX);
+	soun.sun_family = AF_UNIX;
+	strncpy(soun.sun_path, dargs[0], UNIX_PATH_MAX);
 	
-	if ((err = connect(sfd, (struct sockaddr *)&sun, sizeof(struct sockaddr_un)))) {
+	if ((err = connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))) {
 	    zwarnnam(nam, "connection failed: %e", NULL, errno);
 	    close(sfd);
 	    return 1;
@@ -241,7 +242,7 @@ bin_zsocket(char *nam, char **args, char *ops, int func)
 	    setiparam("REPLY", sfd);
 
 	    if (verbose)
-		printf("%s is now on fd %d\n", sun.sun_path, sfd);
+		printf("%s is now on fd %d\n", soun.sun_path, sfd);
 	}
 	
     }