am d57eb903: am b145b5ef: Merge "Fix broken pointer overflow check ns_name_unpack()"

* commit 'd57eb903c1ca2f798ab6a9ab0f9c84678b0f3025':
  Fix broken pointer overflow check ns_name_unpack()
This commit is contained in:
Calin Juravle 2014-03-07 19:29:51 +00:00 committed by Android Git Automerger
commit c3957eea26

View File

@ -473,11 +473,14 @@ ns_name_unpack2(const u_char *msg, const u_char *eom, const u_char *src,
_DIAGASSERT(__type_fit(int, srcp - src + 1));
len = (int)(srcp - src + 1);
}
srcp = msg + (((n & 0x3f) << 8) | (*srcp & 0xff));
if (srcp < msg || srcp >= eom) { /* Out of range. */
// BEGIN android-changed: safer pointer overflow check
l = (((n & 0x3f) << 8) | (*srcp & 0xff));
if (l >= eom - msg) { /* Out of range. */
errno = EMSGSIZE;
return (-1);
}
srcp = msg + l;
// END android-changed
checked += 2;
/*
* Check for loops in the compressed name;