Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #61706

Re: Method other than strlen to check for truncation with fgets?

From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Method other than strlen to check for truncation with fgets?
Date 2015-05-07 14:15 -0400
Organization A noiseless patient Spider
Message-ID <miga1f$ndc$1@dont-email.me> (permalink)
References (1 earlier) <mieros$th2$1@speranza.aioe.org> <mieugr$lut$1@dont-email.me> <mif5uq$k6r$1@speranza.aioe.org> <87oalwjsh4.fsf@kst-u.example.com> <mig68n$798$1@speranza.aioe.org>

Show all headers | View raw


On 05/07/2015 01:09 PM, Lőrinczy Zsigmond wrote:
>> To be clear, that's gcc compile-time behavior when processing a source
>> file containing null characters.  Handling of C source files needn't be
>> consistent with run-time handling of text streams; compilers don't even
>> have to be implemented in C.
> 
> You are right in every point,
> but neither of them disproves my statements:
> 
> 1. (supposed) text-files might contain binary zeroes
> 2. it is still possible to handle them in C

Useful handling of files opened in text mode that violate the
requirements specified in 7.21.2 might be possible, but if so, only
because some source other than the C standard provides an alternative to
the guarantee that 7.21.2 fails to provide for such files. If you can't
be sure that the data you're reading in matches the data that was
written to the file, what useful processing can you do with that data?
-- 
James Kuyper

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-06 12:35 -0700
  Re: Method other than strlen to check for truncation with fgets? Barry Schwarz <schwarzb@dqel.com> - 2015-05-06 15:14 -0700
    Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-06 16:14 -0700
      Re: Method other than strlen to check for truncation with fgets? Barry Schwarz <schwarzb@dqel.com> - 2015-05-06 17:51 -0700
      Re: Method other than strlen to check for truncation with fgets? Tim Rentsch <txr@alumni.caltech.edu> - 2015-05-06 18:23 -0700
        Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 10:07 -0700
          Re: Method other than strlen to check for truncation with fgets? Tim Rentsch <txr@alumni.caltech.edu> - 2015-05-07 16:06 -0700
  Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-06 22:20 -0400
    Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 10:29 -0700
      Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 14:09 -0400
        Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 12:48 -0700
          Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 17:01 -0400
            Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-08 10:59 -0700
              Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-08 14:48 -0400
              Re: Method other than strlen to check for truncation with fgets? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-05-08 18:37 +0000
                Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-08 15:06 -0400
  Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <nospam@for.me> - 2015-05-07 07:04 +0200
    Re: Method other than strlen to check for truncation with fgets? Richard Heathfield <rjh@cpax.org.uk> - 2015-05-07 06:52 +0100
      Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-05-07 09:58 +0200
        Re: Method other than strlen to check for truncation with fgets? Stephen Sprunk <stephen@sprunk.org> - 2015-05-07 09:12 -0500
        Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 08:51 -0700
          Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-05-07 19:09 +0200
            Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 14:15 -0400
    Re: Method other than strlen to check for truncation with fgets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-07 11:31 +0100
      Re: Method other than strlen to check for truncation with fgets? Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-05-07 15:41 +0200
        Re: Method other than strlen to check for truncation with fgets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-08 02:44 +0100
          Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 23:24 -0400
            Re: Method other than strlen to check for truncation with fgets? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-08 04:41 +0100
      Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 08:49 -0700
        Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 12:19 -0400
        Re: Method other than strlen to check for truncation with fgets? glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-05-07 18:08 +0000
    Re: Method other than strlen to check for truncation with fgets? James Kuyper <jameskuyper@verizon.net> - 2015-05-07 12:19 -0400
      Re: Method other than strlen to check for truncation with fgets? mathog <dmathog@gmail.com> - 2015-05-07 09:57 -0700
  Re: Method other than strlen to check for truncation with fgets? Siri Cruz <chine.bleu@yahoo.com> - 2015-05-07 11:31 -0700
    Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 12:00 -0700
      Re: Method other than strlen to check for truncation with fgets? Siri Cruz <chine.bleu@yahoo.com> - 2015-05-07 12:44 -0700
        Re: Method other than strlen to check for truncation with fgets? Keith Thompson <kst-u@mib.org> - 2015-05-07 14:03 -0700
          Re: Method other than strlen to check for truncation with fgets? Siri Cruz <chine.bleu@yahoo.com> - 2015-05-07 15:28 -0700

csiph-web