cherry-pick.70c65d2.fix-off-by-one.patch 666 B

1234567891011121314151617
  1. Upstream-Author: Christos Zoulas <christos@zoulas.com>
  2. Date: Tue Mar 4 17:42:19 2014 +0000
  3. Upstream-Commit: 70c65d2e1841491f59168db1f905e8b14083fb1c
  4. Description:
  5. off by one in out of bounds calculations (Jan Kaluza)
  6. --- a/src/softmagic.c
  7. +++ b/src/softmagic.c
  8. @@ -71,7 +71,7 @@
  9. private void cvt_32(union VALUETYPE *, const struct magic *);
  10. private void cvt_64(union VALUETYPE *, const struct magic *);
  11. -#define OFFSET_OOB(n, o, i) ((n) < (o) || (i) >= ((n) - (o)))
  12. +#define OFFSET_OOB(n, o, i) ((n) < (o) || (i) > ((n) - (o)))
  13. /*
  14. * softmagic - lookup one file in parsed, in-memory copy of database
  15. * Passed the name and FILE * of one file to be typed.