daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
923a60
From 605a35e6e8dcb2518a1fa8f92fb5fb00a0419345 Mon Sep 17 00:00:00 2001
923a60
From: David Herrmann <dh.herrmann@gmail.com>
923a60
Date: Fri, 29 Apr 2016 12:13:06 +0200
923a60
Subject: [PATCH] basic: fix error/memleak in socket-util
923a60
923a60
Probably a typo, checking 'ret' instead of the return value 'p'. This
923a60
might cause the function to return failure, even though it succeeded.
923a60
Furthermore, it might leak resources.
923a60
923a60
Cherry-picked from: 0810bc568ace619b16e440805e93256730d45541
923a60
Related: #1331667
923a60
---
923a60
 src/shared/socket-util.c | 2 +-
923a60
 1 file changed, 1 insertion(+), 1 deletion(-)
923a60
923a60
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
923a60
index a4e26b1d8c..407d0afee3 100644
923a60
--- a/src/shared/socket-util.c
923a60
+++ b/src/shared/socket-util.c
923a60
@@ -544,7 +544,7 @@ int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_
923a60
 
923a60
                 } else {
923a60
                         p = strndup(sa->un.sun_path, sizeof(sa->un.sun_path));
923a60
-                        if (!ret)
923a60
+                        if (!p)
923a60
                                 return -ENOMEM;
923a60
                 }
923a60