[PATCH 7 of 7] chg: raise the length limit of socket path

Jun Wu quark at fb.com
Sun Apr 3 22:30:54 EDT 2016


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1459729375 -3600
#      Mon Apr 04 01:22:55 2016 +0100
# Node ID f280444a28189c58641751a01447af1b80978115
# Parent  f7c6cfae4dba1c48a63bdea1b9aa816e7f634d02
chg: raise the length limit of socket path

Previous patches made both the chg server and the client use relative paths
for connect and bind. Now it's time to raise the length limit. This patch
replace UNIX_PATH_MAX (usually 107) with PATH_MAX (usually 4096) so chg will
work even with very long $CHGSOCKNAME as long as the basename is short.

diff --git a/contrib/chg/chg.c b/contrib/chg/chg.c
--- a/contrib/chg/chg.c
+++ b/contrib/chg/chg.c
@@ -25,14 +25,14 @@
 #include "hgclient.h"
 #include "util.h"
 
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX (sizeof(((struct sockaddr_un *)NULL)->sun_path))
+#ifndef PATH_MAX
+#define PATH_MAX 4096
 #endif
 
 struct cmdserveropts {
-	char sockname[UNIX_PATH_MAX];
-	char redirectsockname[UNIX_PATH_MAX];
-	char lockfile[UNIX_PATH_MAX];
+	char sockname[PATH_MAX];
+	char redirectsockname[PATH_MAX];
+	char lockfile[PATH_MAX];
 	size_t argsize;
 	const char **args;
 	int lockfd;
@@ -130,7 +130,7 @@
 static void setcmdserveropts(struct cmdserveropts *opts)
 {
 	int r;
-	char sockdir[UNIX_PATH_MAX];
+	char sockdir[PATH_MAX];
 	const char *envsockname = getenv("CHGSOCKNAME");
 	if (!envsockname) {
 		/* by default, put socket file in secure directory


More information about the Mercurial-devel mailing list