Skip to contentSkip to conversation

mount.cifs: fix handling of scopeid in resolve_host

PATCH In review Jeff Layton 1 participant 2 messages Feb 15, 2011 – Feb 18, 2011 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mount.cifs: fix handling of scopeid in resolve_host

We get a pointer to the end of the address string (ipaddr), but the call snprintf and pass in tmpbuf which is a pointer to the beginning of the address string. If someone passes in an address with a scopeid then we end up overwriting the entire address string.

---
 resolve_host.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
resolve_host.c +1 -1
index 7687503..69859a3 100644
@@ -71,7 +71,7 @@ int resolve_host(const char *host, char *addrstr)
 			if (sin6->sin6_scope_id) {
 				len = strnlen(tmpbuf, sizeof(tmpbuf));
 				ipaddr = tmpbuf + len;
-				snprintf(tmpbuf, sizeof(tmpbuf) - len, "%%%u",
+				snprintf(ipaddr, sizeof(tmpbuf) - len, "%%%u",
 					 sin6->sin6_scope_id);
 			}
 			break;
Signature · 1 line
1.7.4

A message that is not in the archive (sent off-list or not yet received): 1297794670-4345-1-git-send-email-jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org

#2 lore raw
Quoted 16 lines · On Tue, 15 Feb 2011 13:31:10 -0500 Jeff Layton…

We get a pointer to the end of the address string (ipaddr), but the call snprintf and pass in tmpbuf which is a pointer to the beginning of the address string. If someone passes in an address with a scopeid then we end up overwriting the entire address string.

---
 resolve_host.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
resolve_host.c +0 -0
index 7687503..69859a3 100644

resolve_host.c int resolve_host(const char *host, char *addrstr) · line 77

Quoted 8 lines
resolve_host.c +1 -1
@@ -71,7 +71,7 @@ int resolve_host(const char *host, char *addrstr)
 			if (sin6->sin6_scope_id) {
 				len = strnlen(tmpbuf, sizeof(tmpbuf));
 				ipaddr = tmpbuf + len;
-				snprintf(tmpbuf, sizeof(tmpbuf) - len, "%%%u",
+				snprintf(ipaddr, sizeof(tmpbuf) - len, "%%%u",
 					 sin6->sin6_scope_id);
 			}
 			break;

Merged, should make 4.9.

Signature · 1 line
Jeff Layton <[email protected]>