mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
[network] Avoid out ouf bounds read in __libc_res_nquerydomain
2012-02-28 Jeff Law <law@redhat.com> * resolv/res_query.c (__libc_res_nquerydomain): Avoid out of bounds read.
This commit is contained in:
committed by
Carlos O'Donell
parent
1f393a11f6
commit
8fdceb2efd
@ -1,3 +1,8 @@
|
|||||||
|
2012-02-29 Jeff Law <law@redhat.com>
|
||||||
|
|
||||||
|
* resolv/res_query.c (__libc_res_nquerydomain): Avoid
|
||||||
|
out of bounds read.
|
||||||
|
|
||||||
2012-02-29 Marek Polacek <polacek@redhat.com>
|
2012-02-29 Marek Polacek <polacek@redhat.com>
|
||||||
|
|
||||||
[BZ #13706]
|
[BZ #13706]
|
||||||
|
@ -556,12 +556,16 @@ __libc_res_nquerydomain(res_state statp,
|
|||||||
* copy without '.' if present.
|
* copy without '.' if present.
|
||||||
*/
|
*/
|
||||||
n = strlen(name);
|
n = strlen(name);
|
||||||
if (n >= MAXDNAME) {
|
|
||||||
|
/* Decrement N prior to checking it against MAXDNAME
|
||||||
|
so that we detect a wrap to SIZE_MAX and return
|
||||||
|
a reasonable error. */
|
||||||
|
n--;
|
||||||
|
if (n >= MAXDNAME - 1) {
|
||||||
RES_SET_H_ERRNO(statp, NO_RECOVERY);
|
RES_SET_H_ERRNO(statp, NO_RECOVERY);
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
n--;
|
if (name[n] == '.') {
|
||||||
if (n >= 0 && name[n] == '.') {
|
|
||||||
strncpy(nbuf, name, n);
|
strncpy(nbuf, name, n);
|
||||||
nbuf[n] = '\0';
|
nbuf[n] = '\0';
|
||||||
} else
|
} else
|
||||||
|
Reference in New Issue
Block a user