Patchwork [5/8] libsi: Handle multiple records in an SRV reply

login
register
mail settings
Submitter Chuck Lever
Date Oct. 21, 2013, 9:51 p.m.
Message ID <20131021215117.38809.31622.stgit@manray.1015granger.net>
Download mbox | patch
Permalink /patch/285286/
State Accepted
Headers show

Comments

Chuck Lever - Oct. 21, 2013, 9:51 p.m.
getservinfo() incorrectly returns ESI_PARSE when a domain has
multiple SRV records.  After each record in the buffer is parsed,
"comp_dn" was not being incremented correctly.  Only the first
record was parsed correctly.

Introduced by commit 0520ee72, "Initial commit," Mar 29 15:37:40
2011.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 src/libsi/getsrvinfo.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/src/libsi/getsrvinfo.c b/src/libsi/getsrvinfo.c
index 931847e..c0f433f 100644
--- a/src/libsi/getsrvinfo.c
+++ b/src/libsi/getsrvinfo.c
@@ -265,16 +265,17 @@  getsrvinfo(const char *srvname, const char *domainname, struct srvinfo **si)
 			status = ESI_PARSE;
 			goto out_free;
 		}
-
 		comp_dn += l;
 
 		record = (struct srv *)&comp_dn[10];
+		comp_dn += 16;
 
-		l = dn_expand(msg, msg + len, comp_dn + 16, exp_dn, NS_MAXDNAME);
+		l = dn_expand(msg, msg + len, comp_dn, exp_dn, NS_MAXDNAME);
 		if (l == -1) {
 			status = ESI_PARSE;
 			goto out_free;
 		}
+		comp_dn += l;
 
 		if (count == 1 && strcmp(exp_dn, ".") == 0) {
 			status = ESI_SERVICE;