Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: sizeof environment variables array = 1? Date: Fri, 09 Jun 2017 08:41:54 -0700 Organization: None to speak of Lines: 33 Message-ID: References: <878tl2v5ge.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="e40ff83086fdd10e487ed4dffbe7e58b"; logging-data="18219"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/d2oKKKNTCmhAT8GRMMmMg" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:zvhFCquJGwZUd4simB0ZveMA5N0= sha1:/QnRZTCsHteXqhfawMlwWrAL4UQ= Xref: csiph.com comp.lang.c:111884 DFS writes: > On 6/8/2017 6:12 PM, Keith Thompson wrote: >> Instead, I strongly suggest you define what constitutes valid input >> for your program, and check for that. > > 'file' returns ASCII in the description, or the extension is .txt. > > That's it. I don't believe the file command reads the entire file, so it might report ASCII for something that contains non-ASCII characters. On systems that support symbolic links, "file" on a symbolic link just says it's a symbolic link; it doesn't report on the contents of a file. I would expect a symlink to a pure ASCII text file to be acceptable, but you would reject it. Unless the target of the symlink happens to have the string ASCII in its name. I can rename any binary file to give it a ".txt" extension. If your program is vulnerable to bad input, that's how someone can break it. If those are your requirements, that's up to you -- but I don't see how the requrements you've given make any sense. There must be some logical basis for the requirements you've stated, but if you're unwilling to discuss that basis (your *real* requirements), we can't help you. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"