public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/5666] New: when getline fails it still allocates a buffer
@ 2008-01-24 21:00 werner_hahn at yahoo dot de
2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: werner_hahn at yahoo dot de @ 2008-01-24 21:00 UTC (permalink / raw)
To: glibc-bugs
This may be a documentation issue.
When passing the getline function a NULL pointer as a buffer it is so kind to
allocate the needed memory. However when you reach for example EOF and the
function returns -1 a buffer of length 120 bytes is allocated anyway which must
be freed manually or else is lost. It took me quite some time to find out why
valgrind always told me of 120 lost bytes. The documentation does not mention
this and so I never suspected this function to be the memory leak.
As getline just functions as a wrapper around getdelim the issue should apply
to that as well.
I give a quick example:
char *line = NULL;
unsigned int count = 0;
count = getline(&line, &count, file_descriptor);
if(count == -1) // now line points to 120 bytes of junk
{
free(line); // without this free the buffer pointed to by line is lost
return NULL;
}
--
Summary: when getline fails it still allocates a buffer
Product: glibc
Version: 2.3.6
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: werner_hahn at yahoo dot de
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=5666
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de
@ 2008-01-24 21:04 ` drepper at redhat dot com
2008-01-25 9:33 ` werner_hahn at yahoo dot de
2008-03-04 18:35 ` drepper at redhat dot com
2 siblings, 0 replies; 11+ messages in thread
From: drepper at redhat dot com @ 2008-01-24 21:04 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2008-01-24 21:03 -------
Do not report problems against anything but the current mainline version.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WORKSFORME
http://sourceware.org/bugzilla/show_bug.cgi?id=5666
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de
2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com
@ 2008-01-25 9:33 ` werner_hahn at yahoo dot de
2008-03-04 18:35 ` drepper at redhat dot com
2 siblings, 0 replies; 11+ messages in thread
From: werner_hahn at yahoo dot de @ 2008-01-25 9:33 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From werner_hahn at yahoo dot de 2008-01-25 09:32 -------
By looking at the source it seems the issue is present in the current version
too.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|WORKSFORME |
Version|2.3.6 |unspecified
http://sourceware.org/bugzilla/show_bug.cgi?id=5666
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de
2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com
2008-01-25 9:33 ` werner_hahn at yahoo dot de
@ 2008-03-04 18:35 ` drepper at redhat dot com
2 siblings, 0 replies; 11+ messages in thread
From: drepper at redhat dot com @ 2008-03-04 18:35 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2008-03-04 18:35 -------
There is nothing wrong with the implementation. The buffer, when allocated, is
always the callers problem. The whole concept of getline is to reuse buffers.
We do not want the getline/getdelim function arbitrarily free the buffer.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |INVALID
http://sourceware.org/bugzilla/show_bug.cgi?id=5666
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
` (5 preceding siblings ...)
2014-04-03 22:24 ` cvs-commit at gcc dot gnu.org
@ 2014-07-02 7:45 ` fweimer at redhat dot com
6 siblings, 0 replies; 11+ messages in thread
From: fweimer at redhat dot com @ 2014-07-02 7:45 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=5666
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
` (4 preceding siblings ...)
2014-04-03 22:24 ` vapier at gentoo dot org
@ 2014-04-03 22:24 ` cvs-commit at gcc dot gnu.org
2014-07-02 7:45 ` fweimer at redhat dot com
6 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2014-04-03 22:24 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=5666
--- Comment #9 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 1c21d115e3e47cd66007341de4bae5c4b0a2d547 (commit)
from fcccd51286acbf9c19ac57ab7143e257d58323fd (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1c21d115e3e47cd66007341de4bae5c4b0a2d547
commit 1c21d115e3e47cd66007341de4bae5c4b0a2d547
Author: David Svoboda <svoboda@cert.org>
Date: Wed Apr 2 05:13:02 2014 -0400
manual: clarify buffer behavior in getline [BZ #5666]
If the user has requested automatic buffer creation, getline may create
it and not free things when an error occurs. That means the user is
always responsible for calling free() regardless of the return value.
The current documentation does not explicitly cover this which leaves it
slightly ambiguous to the reader. So clarify things.
URL: https://sourceware.org/bugzilla/show_bug.cgi?id=5666
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 ++++++
manual/stdio.texi | 3 ++-
2 files changed, 8 insertions(+), 1 deletions(-)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
` (3 preceding siblings ...)
2014-04-02 9:26 ` vapier at gentoo dot org
@ 2014-04-03 22:24 ` vapier at gentoo dot org
2014-04-03 22:24 ` cvs-commit at gcc dot gnu.org
2014-07-02 7:45 ` fweimer at redhat dot com
6 siblings, 0 replies; 11+ messages in thread
From: vapier at gentoo dot org @ 2014-04-03 22:24 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=5666
--- Comment #8 from Mike Frysinger <vapier at gentoo dot org> ---
(In reply to Mike Frysinger from comment #7)
https://sourceware.org/git/?p=glibc.git;a=commit;h=1c21d115e3e47cd66007341de4bae5c4b0a2d547
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
` (2 preceding siblings ...)
2012-01-03 21:32 ` svoboda at cert dot org
@ 2014-04-02 9:26 ` vapier at gentoo dot org
2014-04-03 22:24 ` vapier at gentoo dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: vapier at gentoo dot org @ 2014-04-02 9:26 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=5666
Mike Frysinger <vapier at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vapier at gentoo dot org
--- Comment #7 from Mike Frysinger <vapier at gentoo dot org> ---
(In reply to David Svoboda from comment #6)
https://sourceware.org/ml/libc-alpha/2014-04/msg00027.html
btw, if you have other pending issues like this, please re-open them for us to
locate/resolve
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
2011-12-09 16:18 ` svoboda at cert dot org
2011-12-18 1:47 ` drepper.fsp at gmail dot com
@ 2012-01-03 21:32 ` svoboda at cert dot org
2014-04-02 9:26 ` vapier at gentoo dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: svoboda at cert dot org @ 2012-01-03 21:32 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=5666
--- Comment #6 from David Svoboda <svoboda at cert dot org> 2012-01-03 21:31:54 UTC ---
Created attachment 6142
--> http://sourceware.org/bugzilla/attachment.cgi?id=6142
Amended the documentation to reflect getline() behavior during an error
As requested, here is a patch to 'fix' the documentation.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
2011-12-09 16:18 ` svoboda at cert dot org
@ 2011-12-18 1:47 ` drepper.fsp at gmail dot com
2012-01-03 21:32 ` svoboda at cert dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-12-18 1:47 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=5666
Ulrich Drepper <drepper.fsp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |INVALID
--- Comment #5 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-12-18 01:46:44 UTC ---
If you want the documentation to be changed send a patch. This has nothing to
do with this bug. Don't reopen it.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libc/5666] when getline fails it still allocates a buffer
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
@ 2011-12-09 16:18 ` svoboda at cert dot org
2011-12-18 1:47 ` drepper.fsp at gmail dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: svoboda at cert dot org @ 2011-12-09 16:18 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=5666
David Svoboda <svoboda at cert dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |svoboda at cert dot org
Resolution|INVALID |
--- Comment #4 from David Svoboda <svoboda at cert dot org> 2011-12-09 16:18:26 UTC ---
The bug is in the documentation. The info page does not resolve the question of
whether or not getline() fills lineptr with a pointer that must be freed when
it also returns -1. And there are several coding examples that indicate that
the user need not free the pointer.
In other words, the docs leave the question unresolved, and several online code
samples get the answer wrong. Here is one:
http://stackoverflow.com/questions/735126/are-there-alternate-implementations-of-gnu-getline-interface
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-07-02 7:45 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-24 21:00 [Bug libc/5666] New: when getline fails it still allocates a buffer werner_hahn at yahoo dot de
2008-01-24 21:04 ` [Bug libc/5666] " drepper at redhat dot com
2008-01-25 9:33 ` werner_hahn at yahoo dot de
2008-03-04 18:35 ` drepper at redhat dot com
[not found] <bug-5666-131@http.sourceware.org/bugzilla/>
2011-12-09 16:18 ` svoboda at cert dot org
2011-12-18 1:47 ` drepper.fsp at gmail dot com
2012-01-03 21:32 ` svoboda at cert dot org
2014-04-02 9:26 ` vapier at gentoo dot org
2014-04-03 22:24 ` vapier at gentoo dot org
2014-04-03 22:24 ` cvs-commit at gcc dot gnu.org
2014-07-02 7:45 ` fweimer at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).