Eliminate broken data end calculation in dataLength()
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 23 Mar 2012 12:17:47 +0000 (14:17 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 23 Mar 2012 12:36:34 +0000 (14:36 +0200)
commit0b8c3218027c99a6d92c2ca53fe7f42cf87f30a4
tree064f504576b35668f400d8528c98b76456df2580
parent8a189c638386bee3906033857aa7268c1e0ca22c
Eliminate broken data end calculation in dataLength()

- If the caller doesn't know the end pointer, we dont have a whole lot
  of chance to come up with a reasonable one either. Just assume
  the terminating \0's are there when end boundary is not specified:
  when this happens we're dealing with relatively "trusted" data
  anyway, the more critical case of reading in unknown headers does
  always pass end pointers.
- While capping the end pointer to HEADER_DATA_MAX seems like a
  reasonable thing to do (as was done in commit
  f79909d04e43cbfbbcdc588530a8c8033c5e0a7c), it doesn't really help
  (bad data would likely run past bounds anyway), and it's not right
  either: the pointer can be to a stack address, and the stack can be
  near the top of addressable range, and ptr + HEADER_DATA_MAX can
  cause pointer wraparound. Notably that's exactly what happens
  when running 32bit personality process on 64bit system on Linux,
  at least in case of i386 process on x86_64, causing all sorts of
  breakage..
lib/header.c