🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9232

Re: Missing stdio features.

#9232
From: karl
Date: Wed, 03 Sep 1986 18:55
22 lines
1567 bytes
sun!guy (Guy Harris) writes:
> >FILE *fopenstr(char *str, int len, char *mode)
>It looks straightforward to implement IF you have the 4BSD version of
>standard I/O, where there's a "this is a string" flag for each FILE
>structure.  The S5 version, unfortunately, has only a "char" for the flags,
>not a "short", so it says that the "last" FILE entry, and only that entry,
>is a stream.

Making the last FILE special was indeed a botch, but it isn't necessary to
expand the _flag field to fix it.  Just use (iop->_file == -1) on string
files.

>Given "fopenstr" you can actually provide a version of "sprintf" that
>performs *bounds checking* on the string it's printing into.  (Wow, what a
>unique concept, software that doesn't scribble its data space when a user
>types in a string longer than it expected!)

And given "fopenfxn", you could provide a version of "sprintf" that not only
detects the overflow, but *fixes* it with a realloc()!

Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint
Technical Details
Message-ID: <86900035@haddock>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!ima!haddock!karl
References: <3438@robin.cs.nott.ac.uk>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!ima!haddock!karl
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: Missing stdio features.
Message-ID: <86900035@haddock>
Date: Wed, 3-Sep-86 14:55:00 EDT
Article-I.D.: haddock.86900035
Posted: Wed Sep  3 14:55:00 1986
Date-Received: Wed, 3-Sep-86 21:53:17 EDT
References: <3438@robin.cs.nott.ac.uk>
Lines: 22
Nf-ID: #R:robin.cs.nott.ac.uk:3438:haddock:86900035:000:1020
Nf-From: haddock!karl    Sep  3 14:55:00 1986