mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Do real seek
Catch ftruncate errors PR: 104295 Submitted by: ru (seek)
This commit is contained in:
parent
d7862beb32
commit
b48be86ce1
1 changed files with 11 additions and 3 deletions
|
|
@ -113,9 +113,17 @@ freopen(file, mode, fp)
|
|||
return (NULL);
|
||||
}
|
||||
}
|
||||
if (oflags & O_TRUNC)
|
||||
ftruncate(fp->_file, 0);
|
||||
if (_fseeko(fp, 0, oflags & O_APPEND ? SEEK_END : SEEK_SET,
|
||||
if (oflags & O_TRUNC) {
|
||||
if (ftruncate(fp->_file, (off_t)0) < 0) {
|
||||
sverrno = errno;
|
||||
fclose(fp);
|
||||
FUNLOCKFILE(fp);
|
||||
errno = sverrno;
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
fp->_flags |= __SNPT; /* real seek */
|
||||
if (_fseeko(fp, (off_t)0, oflags & O_APPEND ? SEEK_END : SEEK_SET,
|
||||
0) < 0 && errno != ESPIPE) {
|
||||
sverrno = errno;
|
||||
fclose(fp);
|
||||
|
|
|
|||
Loading…
Reference in a new issue