samba-bugs at samba.org
2011-Aug-05 20:01 UTC
[Bug 8355] New: Use pointer after freeaddrinfo()
https://bugzilla.samba.org/show_bug.cgi?id=8355
Summary: Use pointer after freeaddrinfo()
Product: rsync
Version: 3.0.8
Platform: All
OS/Version: All
Status: NEW
Severity: critical
Priority: P5
Component: core
AssignedTo: wayned at samba.org
ReportedBy: andrey at zonov.org
QAContact: rsync-qa at samba.org
Build and install rsync 3.0.8 then try to connect unavaliable host and
you've
got segmentation fault.
$ rsync rsync://10.0.0.1
rsync: failed to connect to 10.0.0.1 (10.0.0.1): Operation timed out (60)
Segmentation fault: 11
There's an error in open_socket_out() function in socket.c. It's need to
call
freeaddrinfo() in the end of the function. Like this:
--- socket.c.orig 2011-08-05 23:55:06.000000000 +0400
+++ socket.c 2011-08-05 23:55:17.000000000 +0400
@@ -299,7 +299,6 @@
}
break;
}
- freeaddrinfo(res0);
if (s < 0) {
char buf[2048];
@@ -313,6 +312,7 @@
s = -1;
}
+ freeaddrinfo(res0);
free(errnos);
return s;
but there is an another error over calling inet_ntop().
Full patch is in attachment.
--
Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
https://bugzilla.samba.org/show_bug.cgi?id=8355 --- Comment #1 from Andrey Zonov <andrey at zonov.org> 2011-08-05 20:06:14 UTC --- Created attachment 6757 --> https://bugzilla.samba.org/attachment.cgi?id=6757 patch -- Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug.
https://bugzilla.samba.org/show_bug.cgi?id=8355
Wayne Davison <wayned at samba.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Version|3.0.8 |3.0.9
Resolution| |FIXED
--- Comment #2 from Wayne Davison <wayned at samba.org> 2011-08-05
23:11:07 UTC ---
This was fixed in git back on July 11. Thanks, though!
--
Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
https://bugzilla.samba.org/show_bug.cgi?id=8355
Andrey Zonov <andrey at zonov.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
--- Comment #3 from Andrey Zonov <andrey at zonov.org> 2011-08-06 12:36:18
UTC ---
(In reply to comment #2)> This was fixed in git back on July 11. Thanks, though!
I think I found another bug over there. Please, inspect this patch:
diff --git a/socket.c b/socket.c
index 0f596e0..84f9b0c 100644
--- a/socket.c
+++ b/socket.c
@@ -303,7 +303,7 @@ int open_socket_out(char *host, int port, const char
*bind_addr,
}
if (DEBUG_GTE(CONNECT, 2)) {
char buf[2048];
- if ((error = getnameinfo(res->ai_addr,
res->ai_addrlen,
buf, sizeof buf, NULL, 0, NI_NUMERICHOST) != 0))
+ if ((error = getnameinfo(res->ai_addr,
res->ai_addrlen,
buf, sizeof buf, NULL, 0, NI_NUMERICHOST)) != 0)
snprintf(buf, sizeof buf, "*getnameinfo
failure: %s*", gai_strerror(error));
rprintf(FINFO, "Connected to %s (%s)\n", h,
buf);
}
@@ -315,7 +315,7 @@ int open_socket_out(char *host, int port, const char
*bind_addr,
for (res = res0, j = 0; res; res = res->ai_next, j++) {
if (errnos[j] == 0)
continue;
- if ((error = getnameinfo(res->ai_addr,
res->ai_addrlen,
buf, sizeof buf, NULL, 0, NI_NUMERICHOST) != 0))
+ if ((error = getnameinfo(res->ai_addr,
res->ai_addrlen,
buf, sizeof buf, NULL, 0, NI_NUMERICHOST)) != 0)
snprintf(buf, sizeof buf, "*getnameinfo
failure: %s*", gai_strerror(error));
rsyserr(FERROR, errnos[j], "failed to connect to %s
(%s)", h, buf);
}
--
Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
https://bugzilla.samba.org/show_bug.cgi?id=8355
Wayne Davison <wayned at samba.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
--- Comment #4 from Wayne Davison <wayned at samba.org> 2011-08-06
18:24:52 UTC ---
Committed -- much appreciated!
--
Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.