rwrap: Don't dereference NULL when skipping broken records
authorJakub Hrozek <jakub.hrozek@gmail.com>
Tue, 2 Dec 2014 09:35:49 +0000 (10:35 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 2 Dec 2014 10:01:09 +0000 (11:01 +0100)
CID: 83426
CID: 83425

Signed-off-by: Jakub Hrozek <jakub.hrozek@gmail.com>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
src/resolv_wrapper.c

index a0b2821..7211ad0 100644 (file)
@@ -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;