From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@sunsite.dk
Subject: Re: Rebuilding from CVS on Snow Leopard
Date: Tue, 29 Sep 2009 21:05:13 +0900 [thread overview]
Message-ID: <C9CC3A8A-BF22-46DD-A618-BFD7687F746F@kba.biglobe.ne.jp> (raw)
In-Reply-To: <090927225016.ZM17646@torch.brasslantern.com>
At 22:50 -0700 09/09/27, Bart Schaefer wrote:
>gcc -c -I. -DHAVE_CONFIG_H -DMODULE -Wall -Wmissing-prototypes -O2 -
fno-common -o socket..o socket.c
>socket.c: In function 'bin_zsocket':
>socket.c:106: warning: call to __builtin___strncpy_chk will always
overflow destination buffer
>socket.c:235: warning: call to __builtin___strncpy_chk will always
overflow destination buffer
MacOSX (and many BSD's as well?) does not define UNIX_PATH_MAX,
and struct sockaddr_un is defined in sys/un.h as
struct sockaddr_un {
unsigned char sun_len; /* sockaddr len including
null */
sa_family_t sun_family; /* [XSI] AF_UNIX */
char sun_path[104]; /* [XSI] path name (gag) */
};
so we can't define UNIX_PATH_MAX to 108.
I think it would be better to use sizeof(soun.sun_path) in place
of UNIX_PATH_MAX. Or use sizeof(soun.sun_path)-1 so that sun_path
is always null terminated.
Index: Src/Modules/socket.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/socket.c,v
retrieving revision 1.13
diff -u -r1.13 socket.c
--- Src/Modules/socket.c 22 Sep 2009 16:04:15 -0000 1.13
+++ Src/Modules/socket.c 29 Sep 2009 10:11:35 -0000
@@ -33,10 +33,6 @@
#include <sys/socket.h>
#include <sys/un.h>
-#ifndef UNIX_PATH_MAX
-# define UNIX_PATH_MAX 108
-#endif
-
/*
* We need to include the zsh headers later to avoid clashes with
* the definitions on some systems, however we need the configuration
@@ -103,7 +99,7 @@
}
soun.sun_family = AF_UNIX;
- strncpy(soun.sun_path, localfn, UNIX_PATH_MAX);
+ strncpy(soun.sun_path, localfn, sizeof(soun.sun_path)-1);
if (bind(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))
{
@@ -232,7 +228,7 @@
}
soun.sun_family = AF_UNIX;
- strncpy(soun.sun_path, args[0], UNIX_PATH_MAX);
+ strncpy(soun.sun_path, args[0], sizeof(soun.sun_path)-1);
if ((err = connect(sfd, (struct sockaddr *)&soun, sizeof(struct
sockaddr_un)))) {
zwarnnam(nam, "connection failed: %e", errno);
next prev parent reply other threads:[~2009-09-29 12:13 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-28 5:50 Bart Schaefer
2009-09-29 12:05 ` Jun T. [this message]
2009-09-29 14:32 ` Peter Stephenson
2009-09-29 14:44 ` Bart Schaefer
2009-09-29 16:55 ` Jun T.
2009-09-29 17:23 ` Jun T.
2009-09-29 17:41 ` Mikael Magnusson
2009-09-30 16:11 ` Jun T.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C9CC3A8A-BF22-46DD-A618-BFD7687F746F@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).