[PATCH 13/31] rwrap: Don't dereference NULL when skipping broken records.

Andreas Schneider asn at samba.org
Wed Dec 3 07:45:09 MST 2014


From: Jakub Hrozek <jakub.hrozek at gmail.com>

CID: 83426
CID: 83425

Signed-off-by: Jakub Hrozek <jakub.hrozek at gmail.com>
Reviewed-by: Michael Adam <obnox at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Signed-off-by: Andreas Schneider <asn at samba.org>
---
 lib/resolv_wrapper/resolv_wrapper.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/resolv_wrapper/resolv_wrapper.c b/lib/resolv_wrapper/resolv_wrapper.c
index a0b2821..7211ad0 100644
--- a/lib/resolv_wrapper/resolv_wrapper.c
+++ b/lib/resolv_wrapper/resolv_wrapper.c
@@ -678,12 +678,6 @@ static int rwrap_get_record(const char *hostfile, unsigned recursion,
 		NEXT_KEY(rec_type, key);
 		NEXT_KEY(key, value);
 
-		q = value;
-		while(q[0] != '\n' && q[0] != '\0') {
-			q++;
-		}
-		q[0] = '\0';
-
 		if (key == NULL || value == NULL) {
 			RWRAP_LOG(RWRAP_LOG_WARN,
 				"Malformed line: not enough parts, use \"rec_type key data\n"
@@ -691,6 +685,12 @@ static int rwrap_get_record(const char *hostfile, unsigned recursion,
 			continue;
 		}
 
+		q = value;
+		while(q[0] != '\n' && q[0] != '\0') {
+			q++;
+		}
+		q[0] = '\0';
+
 		if (TYPE_MATCH(type, ns_t_a, rec_type, "A", key, query)) {
 			rc = rwrap_create_fake_a_rr(key, value, rr);
 			break;
-- 
2.1.3




More information about the samba-technical mailing list