Patchwork [7/8] libsi: Compute the end-of-buffer pointer once

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

Comments

Chuck Lever - Oct. 21, 2013, 9:51 p.m.
Clean up.

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

Patch

diff --git a/src/libsi/getsrvinfo.c b/src/libsi/getsrvinfo.c
index 5338454..b60a915 100644
--- a/src/libsi/getsrvinfo.c
+++ b/src/libsi/getsrvinfo.c
@@ -206,7 +206,7 @@  insert_srvinfo_sorted(struct srvinfo **head, struct srvinfo *entry)
 int
 getsrvinfo(const char *srvname, const char *domainname, struct srvinfo **si)
 {
-	unsigned char *msg, *comp_dn;
+	unsigned char *msg, *eom, *comp_dn;
 	struct srvinfo *results;
 	unsigned short count, i;
 	int status, len;
@@ -250,9 +250,10 @@  getsrvinfo(const char *srvname, const char *domainname, struct srvinfo **si)
 		status = ESI_NODATA;
 		goto out;
 	}
+	eom = msg + len;
 
 	comp_dn = &msg[HFIXEDSZ];
-	comp_dn += dn_skipname(comp_dn, msg + len) + QFIXEDSZ;
+	comp_dn += dn_skipname(comp_dn, eom) + QFIXEDSZ;
 
 	results = NULL;
 	for (i = 0; i < count; i++) {
@@ -260,7 +261,7 @@  getsrvinfo(const char *srvname, const char *domainname, struct srvinfo **si)
 		struct srv *record;
 		int l;
 
-		l = dn_expand(msg, msg + len, comp_dn, exp_dn, NS_MAXDNAME);
+		l = dn_expand(msg, eom, comp_dn, exp_dn, NS_MAXDNAME);
 		if (l == -1) {
 			status = ESI_PARSE;
 			goto out_free;
@@ -270,7 +271,7 @@  getsrvinfo(const char *srvname, const char *domainname, struct srvinfo **si)
 		record = (struct srv *)&comp_dn[10];
 		comp_dn += 16;
 
-		l = dn_expand(msg, msg + len, comp_dn, exp_dn, NS_MAXDNAME);
+		l = dn_expand(msg, eom, comp_dn, exp_dn, NS_MAXDNAME);
 		if (l == -1) {
 			status = ESI_PARSE;
 			goto out_free;