diff options
author | Mark Nunberg <mnunberg@haskalah.org> | 2018-12-05 07:47:05 -0500 |
---|---|---|
committer | Mark Nunberg <mnunberg@haskalah.org> | 2018-12-05 07:47:27 -0500 |
commit | 088d1469b30ba4e51c550cf1ef84580c4575a307 (patch) | |
tree | 6cb5cb4d8847d4d67474bc0027fbdd8f7e95dc78 /net.c | |
parent | 8633a2f32eecb43a0c12e9de1bb358da9e6b7d43 (diff) |
Fix regression when connecting with Unix sockets (#629)
Diffstat (limited to 'net.c')
-rw-r--r-- | net.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -472,7 +472,7 @@ int redisContextConnectBindTcp(redisContext *c, const char *addr, int port, int redisContextConnectUnix(redisContext *c, const char *path, const struct timeval *timeout) { int blocking = (c->flags & REDIS_BLOCK); - struct sockaddr_un sa; + struct sockaddr_un *sa; long timeout_msec = -1; if (redisCreateSocket(c,AF_UNIX) < 0) @@ -499,9 +499,10 @@ int redisContextConnectUnix(redisContext *c, const char *path, const struct time if (redisContextTimeoutMsec(c,&timeout_msec) != REDIS_OK) return REDIS_ERR; - sa.sun_family = AF_UNIX; - strncpy(sa.sun_path,path,sizeof(sa.sun_path)-1); - if (connect(c->fd, (struct sockaddr*)&sa, sizeof(sa)) == -1) { + sa = (struct sockaddr_un*)(c->saddr = malloc(sizeof(struct sockaddr_un))); + sa->sun_family = AF_UNIX; + strncpy(sa->sun_path,path,sizeof(sa->sun_path)-1); + if (connect(c->fd, (struct sockaddr*)sa, sizeof(*sa)) == -1) { if (errno == EINPROGRESS && !blocking) { /* This is ok. */ } else { |