Ver código fonte

usrloc(k): safety check for first record in udomain slot

- reported by David Kovarik, FS#234
(cherry picked from commit 31f404a98b09b5a6270e860574b16c9f9112c305)
Daniel-Constantin Mierla 13 anos atrás
pai
commit
cc952f8469
1 arquivos alterados com 9 adições e 7 exclusões
  1. 9 7
      modules_k/usrloc/udomain.c

+ 9 - 7
modules_k/usrloc/udomain.c

@@ -856,14 +856,16 @@ int get_urecord(udomain_t* _d, str* _aor, struct urecord** _r)
 		sl = aorhash&(_d->size-1);
 		r = _d->table[sl].first;
 
-		for(i = 0; i < _d->table[sl].n; i++) {
-			if((r->aorhash==aorhash) && (r->aor.len==_aor->len)
-						&& !memcmp(r->aor.s,_aor->s,_aor->len)){
-				*_r = r;
-				return 0;
-			}
+		if(r!=NULL) {
+			for(i = 0; i < _d->table[sl].n; i++) {
+				if((r->aorhash==aorhash) && (r->aor.len==_aor->len)
+							&& !memcmp(r->aor.s,_aor->s,_aor->len)){
+					*_r = r;
+					return 0;
+				}
 
-			r = r->next;
+				r = r->next;
+			}
 		}
 	} else {
 		/* search in DB */