Reference: xorg/app/xauth Update DISPLAY parsing to work with new launchd paths in Yosemite

Jon TURNEY jon.turney at dronecode.org.uk
Fri Jan 2 09:42:32 PST 2015


On 31/12/2014 17:47, Alan Coopersmith wrote:
> On 12/31/14 08:11 AM, Colin Harrison wrote:
>> Hi,
>>
>> In the latest commit to xauth there are two added instances of:
>>
>> buf[sizeof(path) - 1] = '\0';
>>
>> shouldn't those be?
>> path[sizeof(path) - 1] = '\0';
>
> Looks like it, for those OS'es without a good enough libc to have strlcpy.

Patch attached.

-------------- next part --------------
From 4a5f2bbb92e17443d5e2dd827cfb45f351d61fff Mon Sep 17 00:00:00 2001
From: Jon TURNEY <jon.turney at dronecode.org.uk>
Date: Fri, 2 Jan 2015 16:18:52 +0000
Subject: [PATCH app/xauth] Fix !HAVE_STRLCPY case
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fix error in the !HAVE_STRLCPY case, introduced in commit
f990dd936b5fd1a40290bb88cde517a0ac38f823

It seems that "path[sizeof(path) - 1]" rather than "buf[sizeof(path) - 1]" must
be meant here, especially as the second instance doesn't even compile...

parsedpy.c: In function ‘parse_displayname’:
parsedpy.c:176:9: error: ‘buf’ undeclared (first use in this function)

Cc: <jeremyhu at apple.com>
Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
---
 gethost.c  | 2 +-
 parsedpy.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gethost.c b/gethost.c
index 028c040..67421f7 100644
--- a/gethost.c
+++ b/gethost.c
@@ -200,7 +200,7 @@ struct addrlist *get_address_info (
 	    strlcpy(path, fulldpyname, sizeof(path));
 #else
 	    strncpy(path, fulldpyname, sizeof(path));
-	    buf[sizeof(path) - 1] = '\0';
+	    path[sizeof(path) - 1] = '\0';
 #endif
 	    if (0 == stat(path, &sbuf)) {
 		is_path_to_socket = 1;
diff --git a/parsedpy.c b/parsedpy.c
index 70c85ce..97988d3 100644
--- a/parsedpy.c
+++ b/parsedpy.c
@@ -173,7 +173,7 @@ parse_displayname (const char *displayname,
         strlcpy(path, displayname, sizeof(path));
 #else
         strncpy(path, displayname, sizeof(path));
-        buf[sizeof(path) - 1] = '\0';
+        path[sizeof(path) - 1] = '\0';
 #endif
         if (0 == stat(path, &sbuf)) {
             family = FamilyLocal;
-- 
2.1.1



More information about the xorg-devel mailing list