gets() is dead

J

jacob navia

In the discussion group comp.std.c Mr Gwyn wrote:

< quote >

.... gets has been declared an obsolescent feature and
deprecated, as a direct result of my submitting a DR about it
(which originally suggested a less drastic change). (The official
impact awaits wrapping up the latest batch of TCs into a formal
amending document, and getting it approved and published.)

< end quote >

This is a very positive development. After all those discussions,
reason prevailed and we got rid of that wart.

It *is* possible to influence the comitee as it seems.
This is good news.

jacob
 
G

Gregor H.

< quote >

... gets has been declared an obsolescent feature and
deprecated, as a direct result of my submitting a DR about it
(which originally suggested a less drastic change). (The official
impact awaits wrapping up the latest batch of TCs into a formal
amending document, and getting it approved and published.)

< end quote >

R.I.P.


G.
 
K

Keith Thompson

Gregor H. said:

It's not dead yet. "Deprecated" merely means that it can be
considered for removal in the next version of the standard (which
presumably will be released some time after C99 actually catches on).
Conforming implementations are still required to support gets().

But this is the first step in getting rid of it.
 
R

Richard Heathfield

Keith Thompson said:

Conforming implementations are still required to support gets().

But this is the first step in getting rid of it.

Surely the first step was the continual rage and horror expressed at its
prolonged survival, over a period of many years, by a great many
people, until ISO were embarrassed by their own inadequate explanations
for its continued existence?

Next stop: unmodified %s in scanf.
 
K

Keith Thompson

Richard Heathfield said:
Keith Thompson said:



Surely the first step was the continual rage and horror expressed at its
prolonged survival, over a period of many years, by a great many
people, until ISO were embarrassed by their own inadequate explanations
for its continued existence?

Yeah, that too.
 
E

Eric Sosman

Richard said:
Keith Thompson said:



Surely the first step was the continual rage and horror expressed at its
prolonged survival, over a period of many years, by a great many
people, until ISO were embarrassed by their own inadequate explanations
for its continued existence?

Next stop: unmodified %s in scanf.

.... along with unrestricted "[%", I guess. But there's no
compelling reason to remove either of them from sscanf() ...
 
C

CBFalconer

Richard said:
Keith Thompson said:



Surely the first step was the continual rage and horror expressed
at its prolonged survival, over a period of many years, by a great
many people, until ISO were embarrassed by their own inadequate
explanations for its continued existence?

Next stop: unmodified %s in scanf.

Not needed, it can be handled. More useful would be inclusion of
generic routines for numerical input from streams without buffers.
 
A

Al Balmer

On Wed, 25 Apr 2007 01:02:04 +0200, jacob navia
You snipped one rather important line:

"In the discussion group comp.std.c Mr Gwyn wrote:"

Your editing made it appear that this was a quote from Jacob Navia.

Incidentally, I am unable to find this article with a Google Groups
search of comp.std.c. Does anyone have a link?
 
T

Tor Rustad

jacob navia wrote:

[...]
This is a very positive development. After all those discussions,
reason prevailed and we got rid of that wart.

These days, there should be no experienced C programmers using gets()
in security sensitive programs anyway, so I don't see the big fuzz about
this.

I have done a number of C code audits in safety-critical systems, and never
seen a single gets(), and didn't expect such a trivial bug either.

Who cares what students use?

I don't.
 
R

Richard Heathfield

Al Balmer said:

Incidentally, I am unable to find this article[*] with a Google Groups
search of comp.std.c. Does anyone have a link?

Message-ID: <[email protected]>

[* An article by Doug Gwyn in comp.std.c, saying that gets() will be
deprecated in the next Standard.]
 
K

Kenny McCormack

jacob navia wrote:

[...]
This is a very positive development. After all those discussions,
reason prevailed and we got rid of that wart.

It's the sort of thing that gets people in this ng hot.
These days, there should be no experienced C programmers using gets()
in security sensitive programs anyway, so I don't see the big fuzz about
this.

I'd have said: no experienced C programmers using gets()
and left it at that. According to the ng regs, everything is "security
sensitive", so including that text is superfluouos.
I have done a number of C code audits in safety-critical systems, and never
seen a single gets(), and didn't expect such a trivial bug either.

Who cares what students use?

I don't.

The anal-retentive freaks in this ng obviously do.
They've got nothing else in their lives, that much is clear.
 
B

Ben Pfaff

Richard Heathfield said:
Al Balmer said:
Incidentally, I am unable to find this article[*] with a Google Groups
search of comp.std.c. Does anyone have a link?

Message-ID: <[email protected]>

[* An article by Doug Gwyn in comp.std.c, saying that gets() will be
deprecated in the next Standard.]

Indeed, I can't find this via Google. But my local news server
has it. See below:

----------------------------------------------------------------------

From: "Douglas A. Gwyn" <[email protected]>
Subject: Re: security enhacement to C runtime library (XXX_s)
Newsgroups: comp.std.c
Date: Tue, 24 Apr 2007 21:47:36 GMT
Organization: U.S. Army Research Laboratory

Now explain to me what can you really in a practical sense do about
this. If C had exception handling, then you could make a case, but it
doesn't so? You're going to call exit(-1) instead? I hope you saved
all your open documents in the program.

Because the behavior is controlled, you can safely save the state
of the work files, etc. Indeed, you can even simulate throwing an
exception by invoking jongjmp to regain control at a convenient
point in the overall algorithm. There are several implementations
of nested exception handling packages in Standard C.

With undefined behavior, you typically get a random crash leaving
data in a corrupted state, or worse yet get exploited by a "hacker"
who uses the overrun for nefarious purposes under *his* control.
Thus creating a new code synchronization issue. Congratulations. You
don't have any mathematicians (people who understand what a
mathematical closure is I mean) or people who have used Ruby, or
Python on the committee do you?

Sure we do. I know it's hard to believe that smart people could
come to any conclusion different from the one you come up with,
but it happens. Often it is because they are balancing a different
set of trade-offs or at least assigning different weights to them.
I had major problems that prevented me from considering contributing
to the ANSI standard:

If you don't participate, how do you expect to impact the outcome?
1) You are not open to the idea of *TAKING THINGS OUT* of the standard
library.

Unless there is really strong justification, altering the behavior
of features which have been relied upon as guaranteed to be supported
on every conforming implementation (including dropping the guarantee
of their existence) does a disservice to the huge amount of existing
code that relies on the guarantees. Therefore, there is *rightly* a
strong predisposition on the part of the standards body to maintain
existing interfaces. However, ...
2) You have overtly distorted reality in your C rationale in the past
to cover up for the embarrassment that is gets().

.... actually, gets has been declared an obsolescent feature and
deprecated, as a direct result of my submitting a DR about it
(which originally suggested a less drastic change). (The official
impact awaits wrapping up the latest batch of TCs into a formal
amending document, and getting it approved and published.)
3) If I were to propose Bstrlib for inclusion into the standard, and
it were to be accepted, it would *WORSEN* Bstrlib, because it would be
included by some/most compiler vendors in a closed-source manner. One
of Bstrlib's capabilities relies on the fact that it is open source
(replaceable allocation functions), and the security statement is
meaningless unless the source is available. So I declined the
potential wide-spread notoriety and usage I might have gotten for
Bstrlib if it were accepted (but lets be honest, you guys would not
have given it a fair shake anyways) in exchange for retaining its
status for maximal capability.

When submitted appropriately within the process, proposals are taken
quite seriously and are given fair consideration. A lot of what has
been standardized started out as such proposals. Of course, they had
active participants promoting, explaining, and shepherding them.
4) When I have made suggestions of proposals in the past I have been
met with nothing but derision from you people. There was also an
excellent and really necessary time generalization proposal (I don't
remember who made it, but it was from a regular here; Dave Tribble
maybe?). I don't see that proposal in the current TR. Its obvious
you people just don't care about important capability issues.

I doubt that anything you submitted for consideration by WG14 has
"met with derision". There was in fact an extended time function
proposal that spun off from an earlier proposal which had been found
to have problems too late in the C99 revision process to make it into
the last version of the standard. Tribble has indeed been working to
refine and improve that, although so far as I recall it has not been
proposed as a Work Item, which would be necessary for the committee
to being working on a TR in that regard. Of course it is unrelated
to the buffer-limits TR.
 
R

Richard Tobin

Incidentally, I am unable to find this article with a Google Groups
search of comp.std.c. Does anyone have a link?

I can't find anything I posted in the last day. I think it must be a
Google problem.

-- Richard
 
C

Christopher Benson-Manica

Tor Rustad said:
Who cares what students use?

Some students graduate. Handing them gets() is like handing them
matches and hoping they don't get anywhere near the flammables.
 
C

Charlton Wilbur

CBM> Some students graduate. Handing them gets() is like handing
CBM> them matches and hoping they don't get anywhere near the
CBM> flammables.

It's considerably easier to deal with recent graduates if you don't
have to beat bad habits out of them before instilling good habits --
and even easier still if they come with good habits instilled.

Charlton
 
A

Al Balmer

Al Balmer said:

Incidentally, I am unable to find this article[*] with a Google Groups
search of comp.std.c. Does anyone have a link?

Message-ID: <[email protected]>

[* An article by Doug Gwyn in comp.std.c, saying that gets() will be
deprecated in the next Standard.]

Thanks, Richard. I don't usually read the group. For some reason,
Google couldn't find the message, even searching for an exact phrase.
Probably it takes some time to get indexed.
 
T

Tor Rustad

Kenny said:
I'd have said: no experienced C programmers using gets()
and left it at that. According to the ng regs, everything is "security
sensitive", so including that text is superfluouos.

Well, it's not, there is no problem using gets(), when the programmer
control the input.

For example, when writing a quick-and-short-lived test module, which is
needed only during development.
 
D

Dave Vandervies

Tor Rustad said:
Well, it's not, there is no problem using gets(), when the programmer
control the input.

For example, when writing a quick-and-short-lived test module, which is
needed only during development.

The problem with that is that quick-and-short-lived code usually isn't.


dave
 
D

Default User

Ben said:
Richard Heathfield said:
Al Balmer said:
Incidentally, I am unable to find this article[*] with a Google
Groups >> search of comp.std.c. Does anyone have a link?
Message-ID: <[email protected]>

[* An article by Doug Gwyn in comp.std.c, saying that gets() will
be deprecated in the next Standard.]

Indeed, I can't find this via Google. But my local news server
has it. See below:

Google is apparently screwed up today. That's leading many GG users
reposting because they think messages didn't go out.

We're now at the "when Google coughs, usenet gets a cold" state.





Brian
 
C

Christopher Benson-Manica

Tor Rustad said:
Well, it's not, there is no problem using gets(), when the programmer
control the input.
For example, when writing a quick-and-short-lived test module, which is
needed only during development.

I don't agree. Very few things are as quick-and-short-lived as they
are originally intended to be. It isn't a great leap from a simple
test to code that gets e-mailed to someone else to demonstrate that X
is broken to code that someone else may cut and paste without paying
attention. I would suggest that any source file making use of gets()
should be deleted within (at most) five minutes of creation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top