]> mj.ucw.cz Git - libucw.git/commitdiff
fix partmap_load() on amd64 with CONFIG_PARTMAP_IS_MMAP
authorRobert Spalek <rspalek@gmail.com>
Wed, 4 Feb 2009 05:09:27 +0000 (21:09 -0800)
committerRobert Spalek <rspalek@gmail.com>
Wed, 4 Feb 2009 05:09:27 +0000 (21:09 -0800)
I don't understand how this could ever have worked.  the left-hand side is -1
and is never larger than right-hand side when comparing signed values.

ucw/partmap.c

index 962b04bfefa00096371bec672894850a61ab906c..93a7e1ba02689b5c3bd4a0f0c5e6c43b81b45db1 100644 (file)
@@ -69,7 +69,7 @@ partmap_load(struct partmap *p, ucw_off_t start, uns size)
   ucw_off_t end = start + size;
   ucw_off_t win_start = start/CPU_PAGE_SIZE * CPU_PAGE_SIZE;
   size_t win_len = PARTMAP_WINDOW;
-  if ((ucw_off_t) (win_start+win_len) > p->file_size)
+  if (win_len > p->file_size - win_start)
     win_len = ALIGN_TO(p->file_size - win_start, CPU_PAGE_SIZE);
   if ((ucw_off_t) (win_start+win_len) < end)
     die("partmap_map: Window is too small for mapping %d bytes", size);