philipl / pifs

πfs - the data-free filesystem!
GNU General Public License v3.0
6.69k stars 290 forks source link

pifs_write and pifs_read #7

Closed xcrash closed 11 years ago

xcrash commented 11 years ago

during writing

for (index = 0; index < SHRT_MAX; index++) {
  if (get_byte(index) == *buf) {
    break;
  }
}
ret = write(info->fh, &index, sizeof index);

if you are not able to find index that makes "(get_byte(index) == *buf" to true, index will be SHRT_MAX or 0...

So when you will decode it as

*buf = (char) get_byte(index);

you will receive wrong value.

philipl commented 11 years ago

In this particular case, it's trivial to show (http://www.reddit.com/r/programming/comments/1k6zg2/why_store_in_disk_when_you_have_%CF%80_%CF%80fs_the/cbm5yky) that every byte's index is found before you reach SHRT_MAX (65536)