From 1722520a2a7c13ae564fbc7ea9bd290dda411a0b Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 26 Nov 2007 09:52:55 +0100 Subject: [PATCH] add some comments to explain len computing --- awesome-client-common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awesome-client-common.c b/awesome-client-common.c index 900c95543..0086e803c 100644 --- a/awesome-client-common.c +++ b/awesome-client-common.c @@ -37,7 +37,9 @@ get_client_addr(const char *display) addr = p_new(struct sockaddr_un, 1); homedir = getenv("HOME"); - path_len = a_strlen(homedir) + a_strlen(CONTROL_UNIX_SOCKET_PATH) + a_strlen(display) + 2; + /* (a_strlen(display) - 1) because we strcat on display + 1 and + * + 3 for /, \0 and possibly 0 if display is NULL */ + path_len = a_strlen(homedir) + a_strlen(CONTROL_UNIX_SOCKET_PATH) + (a_strlen(display) - 1) + 3; if(path_len >= ssizeof(addr->sun_path)) { fprintf(stderr, "error: path of control UNIX domain socket is too long");