offset = max - bytes;
if (whence != SEEK_FORCECUR) {
offset = (offset > max)?max:offset;
- offset = (offset < min)?min:offset;
}
+ // protect against seeking beyond begining.
+ offset = (offset < min)?min:offset;
if (lseek(fs->fd, offset, SEEK_SET) < 0)
return -1;
return 0;
offset = distance + cur;
else if(whence == SEEK_END)
offset = max - distance;
+ // Always protect against seeking past the begining.
+ offset = (offset < min)?min:offset;
if (whence != SEEK_FORCECUR) {
offset = (offset > max)?max:offset;
- offset = (offset < min)?min:offset;
} else if (offset > max) {
int i;
lseek(fs->fd, 0, SEEK_END);
offset = max - sample_offset;
if (whence != SEEK_FORCECUR) {
offset = (offset > max)?max:offset;
- offset = (offset < min)?min:offset;
}
+ // always protect against seeking past begining.
+ offset = (offset < min)?min:offset;
return lseek(fs->fd, offset, SEEK_SET);
}
offset = max - sample_offset;
if (whence != SEEK_FORCECUR) {
offset = (offset > max)?max:offset;
- offset = (offset < min)?min:offset;
}
+ // Always protect against seeking past begining
+ offset = (offset < min)?min:offset;
return lseek(fs->fd, offset, SEEK_SET);
}
offset = max - samples;
if (whence != SEEK_FORCECUR) {
offset = (offset > max)?max:offset;
- offset = (offset < min)?min:offset;
}
+ // always protect the header space.
+ offset = (offset < min)?min:offset;
return lseek(fs->fd,offset,SEEK_SET);
}
offset = distance + cur;
else if(whence == SEEK_END)
offset = max - distance;
+ // always protect against seeking past end of header
+ offset = (offset < min)?min:offset;
if (whence != SEEK_FORCECUR) {
- offset = (offset < min)?min:offset;
offset = (offset > max)?max:offset;
} else if (offset > max) {
int i;