Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
574 B

  1. #include <rangecheck.h>
  2. #include <safemult.h>
  3. /* does an array of "elements" members of size "membersize" starting at
  4. * "arraystart" lie inside buf1[0..len-1]? */
  5. int range_arrayinbuf(const void* buf1,size_t len,
  6. const void* arraystart,size_t elements,size_t membersize) {
  7. size_t alen;
  8. if (sizeof(alen)==8) {
  9. uint64 x;
  10. if (!umult64(elements,membersize,&x)) return 0;
  11. alen=x;
  12. } else {
  13. unsigned long long t=(unsigned long long)elements*membersize;
  14. alen=t;
  15. if (alen!=t) return 0;
  16. }
  17. return range_bufinbuf(buf1,len,arraystart,alen);
  18. }