]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/commit
- Fix two possible overflows when testing if ELF program headers are on
authortijl <tijl@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 21 Mar 2013 16:15:34 +0000 (16:15 +0000)
committertijl <tijl@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 21 Mar 2013 16:15:34 +0000 (16:15 +0000)
commit34a631edc80d05fee976b6c9029a931e026ef1c0
tree5b97fe344ba852bcb8ae0722c3907d8cd6e9f47d
parent78840d3035fce4e4e4201490098d4952539f08fd
- Fix two possible overflows when testing if ELF program headers are on
  the first page:
  1. Cast uint16_t operands in a multiplication to unsigned int because
     otherwise the implicit promotion to int results in a signed
     multiplication that can overflow and the behaviour on integer
     overflow is undefined.
  2. Replace (offset + size > PAGE_SIZE) with (size > PAGE_SIZE - offset)
     because the sum may overflow.
- Use the same tests to see if the path to the interpreter is on the first
  page. There's no overflow here because size is already limited by
  MAXPATHLEN, but the compiler optimises the new tests better. Also fix an
  off-by-one error.
- Simplify tests to see if an ELF note program header is on the first page.
  This also fixes an off-by-one error.

Reviewed by: kib

git-svn-id: svn://svn.freebsd.org/base/stable/9@248587 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/kern/imgact_elf.c