public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/18887] New: memory corruption when using getmntent on blank lines
@ 2015-08-28 20:36 vapier at gentoo dot org
2015-08-29 22:10 ` [Bug libc/18887] " cvs-commit at gcc dot gnu.org
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: vapier at gentoo dot org @ 2015-08-28 20:36 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
Bug ID: 18887
Summary: memory corruption when using getmntent on blank lines
Product: glibc
Version: 2.23
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: vapier at gentoo dot org
CC: drepper.fsp at gmail dot com
Depends on: 17273
Target Milestone: ---
the change introduced in bug 17273 ends up corrupting memory by a single byte
when processing lines that are all whitespace. this can go unnoticed on many
arches, but it seems to trigger frequently on ppc32.
$ cat > test.c <<EOF
#include <mntent.h>
int main(void) {
FILE *fp = setmntent("/etc/fstab", "r");
getmntent(fp);
endmntent(fp);
}
EOF
$ gcc test.c
$ ./a.out
*** Error in `./a.out': double free or corruption (!prev): 0x10021008 ***
======= Backtrace: =========
/lib/libc.so.6(+0x7bcac)[0xfef2cac]
/lib/libc.so.6(+0x83314)[0xfefa314]
/lib/libc.so.6(+0x84270)[0xfefb270]
/lib/libc.so.6(fclose+0x1e8)[0xfee5838]
/lib/libc.so.6(endmntent+0x2c)[0xff5e11c]
/lib/libc.so.6(+0x21b38)[0xfe98b38]
/lib/libc.so.6(+0x21cd8)[0xfe98cd8]
Referenced Bugs:
https://sourceware.org/bugzilla/show_bug.cgi?id=17273
[Bug 17273] getmntent() returns wrong default value for fs_passno
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
@ 2015-08-29 22:10 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:12 ` vapier at gentoo dot org
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-08-29 22:10 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
--- Comment #1 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 b0e805fa0d6fea33745952df7b7f5442ca4c374f (commit)
from 30da407eca459329e060d0412c3fa6710f657e83 (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=b0e805fa0d6fea33745952df7b7f5442ca4c374f
commit b0e805fa0d6fea33745952df7b7f5442ca4c374f
Author: Mike Frysinger <vapier@gentoo.org>
Date: Fri Aug 28 17:08:49 2015 -0400
getmntent: fix memory corruption w/blank lines [BZ #18887]
The fix for BZ #17273 introduced a single byte of memory corruption when
the line is entirely blank. It would walk back past the start of the
buffer if the heap happened to be 0x20 or 0x09 and then write a NUL byte.
buffer = '\n';
end_ptr = buffer;
while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
end_ptr--;
*end_ptr = '\0';
Fix that and rework the tests. Adding the testcase for BZ #17273 to the
existing \040 parser does not really make sense as it's unrelated, and
leads to confusing behavior: it implicitly relies on the new entry being
longer than the previous entry (since it just rewinds the FILE*). Split
it out into its own dedicated testcase instead.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 10 +++++
misc/Makefile | 3 +-
misc/mntent_r.c | 4 +-
.../tst-mntent-blank-corrupt.c | 43 ++++++++-----------
.../tst-mntent-blank-passno.c | 40 ++++++++++--------
misc/tst-mntent.c | 20 ---------
6 files changed, 55 insertions(+), 65 deletions(-)
copy posix/bug-regex35.c => misc/tst-mntent-blank-corrupt.c (60%)
copy math/tst-definitions.c => misc/tst-mntent-blank-passno.c (55%)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
2015-08-29 22:10 ` [Bug libc/18887] " cvs-commit at gcc dot gnu.org
@ 2015-08-29 22:12 ` vapier at gentoo dot org
2015-08-29 22:13 ` cvs-commit at gcc dot gnu.org
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: vapier at gentoo dot org @ 2015-08-29 22:12 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
Mike Frysinger <vapier at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
See Also| |https://bugs.gentoo.org/sho
| |w_bug.cgi?id=558946
Resolution|--- |FIXED
--- Comment #2 from Mike Frysinger <vapier at gentoo dot org> ---
fixed by that commit
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
2015-08-29 22:10 ` [Bug libc/18887] " cvs-commit at gcc dot gnu.org
2015-08-29 22:12 ` vapier at gentoo dot org
@ 2015-08-29 22:13 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:16 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-08-29 22:13 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
--- Comment #3 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, release/2.21/master has been updated
via f2cdbadd8a078482d3b9fc2b59e888c64cc4efae (commit)
from 978908245b2c0f759100708a9966649f7b273664 (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=f2cdbadd8a078482d3b9fc2b59e888c64cc4efae
commit f2cdbadd8a078482d3b9fc2b59e888c64cc4efae
Author: Mike Frysinger <vapier@gentoo.org>
Date: Fri Aug 28 17:08:49 2015 -0400
getmntent: fix memory corruption w/blank lines [BZ #18887]
The fix for BZ #17273 introduced a single byte of memory corruption when
the line is entirely blank. It would walk back past the start of the
buffer if the heap happened to be 0x20 or 0x09 and then write a NUL byte.
buffer = '\n';
end_ptr = buffer;
while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
end_ptr--;
*end_ptr = '\0';
Fix that and rework the tests. Adding the testcase for BZ #17273 to the
existing \040 parser does not really make sense as it's unrelated, and
leads to confusing behavior: it implicitly relies on the new entry being
longer than the previous entry (since it just rewinds the FILE*). Split
it out into its own dedicated testcase instead.
(cherry picked from commit b0e805fa0d6fea33745952df7b7f5442ca4c374f)
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 10 +++++
NEWS | 2 +-
misc/Makefile | 3 +-
misc/mntent_r.c | 4 +-
.../tst-mntent-blank-corrupt.c | 27 +++++++------
.../tst-mntent-blank-passno.c | 40 +++++++++++---------
misc/tst-mntent.c | 20 ----------
7 files changed, 53 insertions(+), 53 deletions(-)
copy libio/test-fmemopen.c => misc/tst-mntent-blank-corrupt.c (60%)
copy math/tst-definitions.c => misc/tst-mntent-blank-passno.c (55%)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
` (2 preceding siblings ...)
2015-08-29 22:13 ` cvs-commit at gcc dot gnu.org
@ 2015-08-29 22:16 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:20 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-08-29 22:16 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
--- Comment #4 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, release/2.22/master has been updated
via 3007f797a1a596e954f44879a5a7267966186ba4 (commit)
from 64c25345714d792b283c8c8469d58f898d1ef109 (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=3007f797a1a596e954f44879a5a7267966186ba4
commit 3007f797a1a596e954f44879a5a7267966186ba4
Author: Mike Frysinger <vapier@gentoo.org>
Date: Fri Aug 28 17:08:49 2015 -0400
getmntent: fix memory corruption w/blank lines [BZ #18887]
The fix for BZ #17273 introduced a single byte of memory corruption when
the line is entirely blank. It would walk back past the start of the
buffer if the heap happened to be 0x20 or 0x09 and then write a NUL byte.
buffer = '\n';
end_ptr = buffer;
while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
end_ptr--;
*end_ptr = '\0';
Fix that and rework the tests. Adding the testcase for BZ #17273 to the
existing \040 parser does not really make sense as it's unrelated, and
leads to confusing behavior: it implicitly relies on the new entry being
longer than the previous entry (since it just rewinds the FILE*). Split
it out into its own dedicated testcase instead.
(cherry picked from commit b0e805fa0d6fea33745952df7b7f5442ca4c374f)
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 10 +++++
NEWS | 2 +-
misc/Makefile | 3 +-
misc/mntent_r.c | 4 +-
.../tst-mntent-blank-corrupt.c | 43 ++++++++-----------
.../tst-mntent-blank-passno.c | 40 ++++++++++--------
misc/tst-mntent.c | 20 ---------
7 files changed, 56 insertions(+), 66 deletions(-)
copy posix/bug-regex35.c => misc/tst-mntent-blank-corrupt.c (60%)
copy math/tst-definitions.c => misc/tst-mntent-blank-passno.c (55%)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
` (3 preceding siblings ...)
2015-08-29 22:16 ` cvs-commit at gcc dot gnu.org
@ 2015-08-29 22:20 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:21 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-08-29 22:20 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
--- Comment #5 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, gentoo/2.21 has been updated
via 460e5da421067eb690ba3b9d11183c4b7db37e4f (commit)
from 43d7ce9238c59c61003994cb26eff4a6a072ebd5 (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=460e5da421067eb690ba3b9d11183c4b7db37e4f
commit 460e5da421067eb690ba3b9d11183c4b7db37e4f
Author: Mike Frysinger <vapier@gentoo.org>
Date: Fri Aug 28 17:08:49 2015 -0400
getmntent: fix memory corruption w/blank lines [BZ #18887]
The fix for BZ #17273 introduced a single byte of memory corruption when
the line is entirely blank. It would walk back past the start of the
buffer if the heap happened to be 0x20 or 0x09 and then write a NUL byte.
buffer = '\n';
end_ptr = buffer;
while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
end_ptr--;
*end_ptr = '\0';
Fix that and rework the tests. Adding the testcase for BZ #17273 to the
existing \040 parser does not really make sense as it's unrelated, and
leads to confusing behavior: it implicitly relies on the new entry being
longer than the previous entry (since it just rewinds the FILE*). Split
it out into its own dedicated testcase instead.
(cherry picked from commit b0e805fa0d6fea33745952df7b7f5442ca4c374f)
(cherry picked from commit f2cdbadd8a078482d3b9fc2b59e888c64cc4efae)
-----------------------------------------------------------------------
Summary of changes:
misc/Makefile | 3 +-
misc/mntent_r.c | 4 +-
.../tst-mntent-blank-corrupt.c | 27 +++++++------
.../tst-mntent-blank-passno.c | 40 +++++++++++---------
misc/tst-mntent.c | 20 ----------
5 files changed, 42 insertions(+), 52 deletions(-)
copy libio/test-fmemopen.c => misc/tst-mntent-blank-corrupt.c (60%)
copy math/tst-definitions.c => misc/tst-mntent-blank-passno.c (55%)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
` (4 preceding siblings ...)
2015-08-29 22:20 ` cvs-commit at gcc dot gnu.org
@ 2015-08-29 22:21 ` cvs-commit at gcc dot gnu.org
2015-09-04 9:48 ` fweimer at redhat dot com
2015-10-29 17:06 ` jsm28 at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-08-29 22:21 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
--- Comment #6 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, gentoo/2.22 has been updated
via ca6a9ce6151759981cc2efd58e053148c7db2fea (commit)
from 0acbb93ebb8cf2a646cc2b685cd13b22d52f1e27 (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=ca6a9ce6151759981cc2efd58e053148c7db2fea
commit ca6a9ce6151759981cc2efd58e053148c7db2fea
Author: Mike Frysinger <vapier@gentoo.org>
Date: Fri Aug 28 17:08:49 2015 -0400
getmntent: fix memory corruption w/blank lines [BZ #18887]
The fix for BZ #17273 introduced a single byte of memory corruption when
the line is entirely blank. It would walk back past the start of the
buffer if the heap happened to be 0x20 or 0x09 and then write a NUL byte.
buffer = '\n';
end_ptr = buffer;
while (end_ptr[-1] == ' ' || end_ptr[-1] == '\t')
end_ptr--;
*end_ptr = '\0';
Fix that and rework the tests. Adding the testcase for BZ #17273 to the
existing \040 parser does not really make sense as it's unrelated, and
leads to confusing behavior: it implicitly relies on the new entry being
longer than the previous entry (since it just rewinds the FILE*). Split
it out into its own dedicated testcase instead.
(cherry picked from commit b0e805fa0d6fea33745952df7b7f5442ca4c374f)
(cherry picked from commit 3007f797a1a596e954f44879a5a7267966186ba4)
-----------------------------------------------------------------------
Summary of changes:
misc/Makefile | 3 +-
misc/mntent_r.c | 4 +-
.../tst-mntent-blank-corrupt.c | 43 ++++++++-----------
.../tst-mntent-blank-passno.c | 40 ++++++++++--------
misc/tst-mntent.c | 20 ---------
5 files changed, 45 insertions(+), 65 deletions(-)
copy posix/bug-regex35.c => misc/tst-mntent-blank-corrupt.c (60%)
copy math/tst-definitions.c => misc/tst-mntent-blank-passno.c (55%)
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
` (5 preceding siblings ...)
2015-08-29 22:21 ` cvs-commit at gcc dot gnu.org
@ 2015-09-04 9:48 ` fweimer at redhat dot com
2015-10-29 17:06 ` jsm28 at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: fweimer at redhat dot com @ 2015-09-04 9:48 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug libc/18887] memory corruption when using getmntent on blank lines
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
` (6 preceding siblings ...)
2015-09-04 9:48 ` fweimer at redhat dot com
@ 2015-10-29 17:06 ` jsm28 at gcc dot gnu.org
7 siblings, 0 replies; 9+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-10-29 17:06 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
Joseph Myers <jsm28 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |2.23
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-10-29 17:06 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-28 20:36 [Bug libc/18887] New: memory corruption when using getmntent on blank lines vapier at gentoo dot org
2015-08-29 22:10 ` [Bug libc/18887] " cvs-commit at gcc dot gnu.org
2015-08-29 22:12 ` vapier at gentoo dot org
2015-08-29 22:13 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:16 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:20 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:21 ` cvs-commit at gcc dot gnu.org
2015-09-04 9:48 ` fweimer at redhat dot com
2015-10-29 17:06 ` jsm28 at gcc dot gnu.org
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).