libc: Do not set errno when mmap(MAP_TRYFIXED) fails.
authorzrj <rimvydas.jasinskas@gmail.com>
Tue, 12 Apr 2016 10:16:05 +0000 (13:16 +0300)
committerzrj <zrj@dragonflybsd.org>
Sat, 16 Apr 2016 07:00:24 +0000 (10:00 +0300)
commite00a0047a7ca4a967f6623f6108883a3bdbce1a6
tree13d5cf5e0cd141c4bfda9481d80ab2fc2141e5d3
parenta85d8d907d7d719a3abe9e0c043c9e220674d966
libc: Do not set errno when mmap(MAP_TRYFIXED) fails.

If this mmap call fails, we'll fall back to moving the allocation to
a different virtual address. Setting errno here might result in
functions further up the call stack misinterpreting an error condition.

Indeed, this surfaced in git's calling of getdelim() in a loop, where
getdelim() would return -1 at EOF, but the caller would find ENOMEM in
errno from a previous, successful, call and interpret that as an OOM.

Fix-to: 07a8ffeaab3fc830679c6836a6ee198ad1a3275f

Suggested-by: aggelos
lib/libc/stdlib/nmalloc.c