Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 59f388a in mainline for uspace/lib/posix/source/unistd.c


Ignore:
Timestamp:
2017-04-04T20:56:47Z (5 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
51774cd
Parents:
8fe46a0
Message:

Fail legacy interfaces if the position is too large for them to represent

HelenOS interfaces support unsigned 64-bit file sizes and offsets. This
is in contrast with C99-ish and POSIX-ish interfaces in libc and libposix.
The legacy API emulation internally uses the native unsigned 64-bit file
sizes and positions and so it may happen that a returned file size or
offset are bigger than the legacy interface can represent. We choose
to report failure in such a case in order to avoid returning wrong
results.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/source/unistd.c

    r8fe46a0 r59f388a  
    245245                break;
    246246        }
     247        if (posix_pos[fildes] > INT64_MAX) {
     248                /* The native width is too large for the POSIX interface. */
     249                errno = ERANGE;
     250                return -1;
     251        }
    247252        return posix_pos[fildes];
    248253}
Note: See TracChangeset for help on using the changeset viewer.