Changeset 59f388a in mainline for uspace/lib/c/generic/io/io.c


Ignore:
Timestamp:
2017-04-04T20:56:47Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
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/c/generic/io/io.c

    r8fe46a0 r59f388a  
    834834off64_t ftell(FILE *stream)
    835835{
     836        /* The native position is too large for the C99-ish interface. */
     837        if (stream->pos - stream->ungetc_chars > INT64_MAX)
     838                return EOF;
     839
    836840        if (stream->error)
    837841                return EOF;
Note: See TracChangeset for help on using the changeset viewer.