You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.6 KiB

  1. From 76ad998e2b6ae852567ff53edb84a0b467c0c9cb Mon Sep 17 00:00:00 2001
  2. From: Jan Seda <hodor@hodor.cz>
  3. Date: Thu, 26 Jun 2014 20:44:05 +0200
  4. Subject: [PATCH 11/12] BUG/MEDIUM: unix: do not unlink() abstract namespace
  5. sockets upon failure.
  6. When bind() fails (function uxst_bind_listener()), the fail path doesn't
  7. consider the abstract namespace and tries to unlink paths held in
  8. uninitiliazed memory (tempname and backname). See the strace excerpt;
  9. the strings still hold the path from test1.
  10. ===============================================================================================
  11. 23722 bind(5, {sa_family=AF_FILE, path=@"test2"}, 110) = -1 EADDRINUSE (Address already in use)
  12. 23722 unlink("/tmp/test1.sock.23722.tmp") = -1 ENOENT (No such file or directory)
  13. 23722 close(5) = 0
  14. 23722 unlink("/tmp/test1.sock.23722.bak") = -1 ENOENT (No such file or directory)
  15. ===============================================================================================
  16. This patch should be backported to 1.5.
  17. (cherry picked from commit 7319b64fc4c9b7e04726816c6cc02f6ecf66a0a4)
  18. ---
  19. src/proto_uxst.c | 4 ++--
  20. 1 file changed, 2 insertions(+), 2 deletions(-)
  21. diff --git a/src/proto_uxst.c b/src/proto_uxst.c
  22. index f83d34e..c9a52ff 100644
  23. --- a/src/proto_uxst.c
  24. +++ b/src/proto_uxst.c
  25. @@ -309,11 +309,11 @@ static int uxst_bind_listener(struct listener *listener, char *errmsg, int errle
  26. if (ret < 0 && errno == ENOENT)
  27. unlink(path);
  28. err_unlink_temp:
  29. - if (!ext)
  30. + if (!ext && path[0])
  31. unlink(tempname);
  32. close(fd);
  33. err_unlink_back:
  34. - if (!ext)
  35. + if (!ext && path[0])
  36. unlink(backname);
  37. err_return:
  38. if (msg && errlen) {
  39. --
  40. 1.8.5.5