openbsd-ports/x11/i3/patches/patch-src_ipc_c
dcoppa 2b72bc6e2f Update to i3-3.5.1
resolve_tilde() function by Christopher Zimmermann
(madroach AT zakweb DOT de): thanks!

OK landry@
2010-09-14 08:54:18 +00:00

57 lines
2.0 KiB
Plaintext

$OpenBSD: patch-src_ipc_c,v 1.1 2010/09/14 08:54:18 dcoppa Exp $
--- src/ipc.c.orig Wed Jun 9 09:58:15 2010
+++ src/ipc.c Thu Jul 15 14:43:03 2010
@@ -91,7 +91,7 @@ static void ipc_send_message(int fd, const unsigned ch
char msg[buffer_size];
char *walk = msg;
- strcpy(walk, "i3-ipc");
+ strncpy(walk, "i3-ipc", buffer_size - 1);
walk += strlen("i3-ipc");
memcpy(walk, &message_size, sizeof(uint32_t));
walk += sizeof(uint32_t);
@@ -502,20 +502,20 @@ void ipc_new_client(EV_P_ struct ev_io *w, int revents
int ipc_create_socket(const char *filename) {
int sockfd;
- char *globbed = glob_path(filename);
- DLOG("Creating IPC-socket at %s\n", globbed);
- char *copy = sstrdup(globbed);
+ char *resolved = resolve_tilde(filename);
+ DLOG("Creating IPC-socket at %s\n", resolved);
+ char *copy = sstrdup(resolved);
const char *dir = dirname(copy);
if (!path_exists(dir))
mkdirp(dir);
free(copy);
/* Unlink the unix domain socket before */
- unlink(globbed);
+ unlink(resolved);
if ((sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
perror("socket()");
- free(globbed);
+ free(resolved);
return -1;
}
@@ -524,14 +524,14 @@ int ipc_create_socket(const char *filename) {
struct sockaddr_un addr;
memset(&addr, 0, sizeof(struct sockaddr_un));
addr.sun_family = AF_LOCAL;
- strcpy(addr.sun_path, globbed);
+ strncpy(addr.sun_path, resolved, sizeof(addr.sun_path) - 1);
if (bind(sockfd, (struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0) {
perror("bind()");
- free(globbed);
+ free(resolved);
return -1;
}
- free(globbed);
+ free(resolved);
set_nonblock(sockfd);
if (listen(sockfd, 5) < 0) {