1. 29 8月, 2018 1 次提交
    • R
      make fmemopen's w+ mode truncate the buffer · f66022dd
      Rich Felker 提交于
      the w+ mode is specified to "truncate the buffer contents". like most
      of fmemopen, exactly what this means is underspecified. mode w and w+
      of course implicitly 'truncate' the buffer if a write from the initial
      position is flushed, so in order for this part of the text about w+
      not to be spurious, it should be interpreted as requiring something
      else, and the obvious reasonable interpretation is that the truncation
      is immediately visible if you attempt to read from the stream or the
      buffer before writing/flushing.
      
      this interpretation agrees with reported conformance test failures.
      f66022dd
  2. 19 4月, 2018 1 次提交
  3. 12 2月, 2018 1 次提交
    • R
      fix incorrect overflow check for allocation in fmemopen · 75cba9c6
      Rich Felker 提交于
      when a null buffer pointer is passed to fmemopen, requesting it
      allocate its own memory buffer, extremely large size arguments near
      SIZE_MAX could overflow and result in underallocation. this results
      from omission of the size of the cookie structure in the overflow
      check but inclusion of it in the calloc call.
      
      instead of accounting for individual small contributions to the total
      allocation size needed, simply reject sizes larger than PTRDIFF_MAX,
      which will necessarily fail anyway. then adding arbitrary fixed-size
      structures is safe without matching up the expressions in the
      comparison and the allocation.
      75cba9c6
  4. 16 6月, 2015 1 次提交
    • R
      refactor stdio open file list handling, move it out of global libc struct · 1b0cdc87
      Rich Felker 提交于
      functions which open in-memory FILE stream variants all shared a tail
      with __fdopen, adding the FILE structure to stdio's open file list.
      replacing this common tail with a function call reduces code size and
      duplication of logic. the list is also partially encapsulated now.
      
      function signatures were chosen to facilitate tail call optimization
      and reduce the need for additional accessor functions.
      
      with these changes, static linked programs that do not use stdio no
      longer have an open file list at all.
      1b0cdc87
  5. 10 11月, 2012 1 次提交
    • R
      always add memory streams to stdio open file list · dc059f03
      Rich Felker 提交于
      per interpretation for austin group issue #626, fflush(0) and exit()
      must block waiting for a lock if another thread has locked a memory
      stream with flockfile. this adds some otherwise-unnecessary
      synchronization cost to use of memory streams, but there was already a
      synchronization cost calling malloc anyway.
      
      previously the stream was only added to the open file list in
      single-threaded programs, so that upon subsequent call to
      pthread_create, locking could be turned on for the stream.
      dc059f03
  6. 09 11月, 2012 1 次提交
    • R
      clean up stdio_impl.h · 835f9f95
      Rich Felker 提交于
      this header evolved to facilitate the extremely lazy practice of
      omitting explicit includes of the necessary headers in individual
      stdio source files; not only was this sloppy, but it also increased
      build time.
      
      now, stdio_impl.h is only including the headers it needs for its own
      use; any further headers needed by source files are included directly
      where needed.
      835f9f95
  7. 07 9月, 2012 1 次提交
    • R
      use restrict everywhere it's required by c99 and/or posix 2008 · 400c5e5c
      Rich Felker 提交于
      to deal with the fact that the public headers may be used with pre-c99
      compilers, __restrict is used in place of restrict, and defined
      appropriately for any supported compiler. we also avoid the form
      [restrict] since older versions of gcc rejected it due to a bug in the
      original c99 standard, and instead use the form *restrict.
      400c5e5c
  8. 05 9月, 2011 4 次提交
    • R
      more fmemopen null termination fixes · d2e061a2
      Rich Felker 提交于
      null termination is only added when current size grows.
      in update modes, null termination is not added if it does not fit
      (i.e. it is not allowed to clobber data).
      
      these rules make very little sense, but that's how it goes..
      d2e061a2
    • R
      fix some fmemopen behaviors · e72ee578
      Rich Felker 提交于
      read should not be allowed past "current size".
      append mode should write at "current size", not buffer size.
      null termination should not be written except when "current size" grows.
      e72ee578
    • R
      fmemopen: fix eof handling, hopefully right this time · 22e45423
      Rich Felker 提交于
      22e45423
    • R
      fmemopen fixes · f81279ff
      Rich Felker 提交于
      disallow seek past end of buffer (per posix)
      fix position accounting to include data buffered for read
      don't set eof flag when no data was requested
      f81279ff
  9. 04 9月, 2011 1 次提交
  10. 14 3月, 2011 1 次提交
  11. 12 2月, 2011 1 次提交