public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno
@ 2014-08-15 3:52 naszar at ya dot ru
2014-08-15 3:53 ` [Bug libc/17273] " naszar at ya dot ru
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: naszar at ya dot ru @ 2014-08-15 3:52 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17273
Bug ID: 17273
Summary: getmntent() returns wrong default value for fs_passno
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
Assignee: unassigned at sourceware dot org
Reporter: naszar at ya dot ru
CC: drepper.fsp at gmail dot com
Created attachment 7747
--> https://sourceware.org/bugzilla/attachment.cgi?id=7747&action=edit
simple test program
man 5 fstab states that if the fifth field (fs_freq) and the sixth field
(fs_passno) is not present a value of zero is returned (i.q.
fs_req=0,fs_passno=0 if there is no fifth and sixth field in /etc/fstab line).
If fourth field ends with '\n' all work fine. But if there is extra tabs or
spaces getmntent() returns garbage in ((struct mntent *) mp)->mnt_passno. It is
because in misc/mntent_r.c:__getmntent_r() at line 167 no checks that sscanf()
returns EOF or no striping for spaces and tabs like it done at line 164 for
example.
In my mashine attached test_mntent (for testtab which also attached) say:
mnt_dir=/home mnt_freq=42 mnt_passno=666
mnt_dir=/home mnt_freq=42 mnt_passno=666
but must:
mnt_dir=/home mnt_freq=42 mnt_passno=666
mnt_dir=/home mnt_freq=0 mnt_passno=0
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
@ 2014-08-15 3:53 ` naszar at ya dot ru
2014-08-15 3:54 ` naszar at ya dot ru
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: naszar at ya dot ru @ 2014-08-15 3:53 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17273
--- Comment #1 from naszar <naszar at ya dot ru> ---
Created attachment 7748
--> https://sourceware.org/bugzilla/attachment.cgi?id=7748&action=edit
test fstab
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
2014-08-15 3:53 ` [Bug libc/17273] " naszar at ya dot ru
@ 2014-08-15 3:54 ` naszar at ya dot ru
2015-08-28 20:34 ` vapier at gentoo dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: naszar at ya dot ru @ 2014-08-15 3:54 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17273
naszar <naszar at ya dot ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |naszar at ya dot ru
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
2014-08-15 3:53 ` [Bug libc/17273] " naszar at ya dot ru
2014-08-15 3:54 ` naszar at ya dot ru
@ 2015-08-28 20:34 ` vapier at gentoo dot org
2015-08-28 20:36 ` vapier at gentoo dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: vapier at gentoo dot org @ 2015-08-28 20:34 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17273
Mike Frysinger <vapier at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Version|unspecified |2.21
Resolution|--- |FIXED
--- Comment #2 from Mike Frysinger <vapier at gentoo dot org> ---
this was discussed here:
https://sourceware.org/ml/libc-alpha/2014-08/msg00476.html
https://sourceware.org/ml/libc-alpha/2014-10/msg00035.html
https://sourceware.org/ml/libc-alpha/2014-12/msg00225.html
https://sourceware.org/ml/libc-alpha/2015-01/msg00109.html
and merged here:
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=fb87ee96d7dd0714d52004e4676629f8d9db732f
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
` (2 preceding siblings ...)
2015-08-28 20:34 ` vapier at gentoo dot org
@ 2015-08-28 20:36 ` vapier at gentoo dot org
2015-08-29 22:11 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ 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=17273
Mike Frysinger <vapier at gentoo dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Blocks| |18887
Referenced Bugs:
https://sourceware.org/bugzilla/show_bug.cgi?id=18887
[Bug 18887] memory corruption when using getmntent on blank lines
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
` (3 preceding siblings ...)
2015-08-28 20:36 ` vapier at gentoo dot org
@ 2015-08-29 22:11 ` cvs-commit at gcc dot gnu.org
2015-08-29 22:13 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2015-08-29 22:11 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=17273
--- 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, 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] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
` (4 preceding siblings ...)
2015-08-29 22:11 ` cvs-commit at gcc dot gnu.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
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ 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=17273
--- 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.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] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
` (5 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
2015-08-29 22:21 ` cvs-commit at gcc dot gnu.org
8 siblings, 0 replies; 10+ 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=17273
--- 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, 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] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
` (6 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
8 siblings, 0 replies; 10+ 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=17273
--- 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.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] 10+ messages in thread
* [Bug libc/17273] getmntent() returns wrong default value for fs_passno
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
` (7 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
8 siblings, 0 replies; 10+ 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=17273
--- Comment #7 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] 10+ messages in thread
end of thread, other threads:[~2015-08-29 22:21 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-15 3:52 [Bug libc/17273] New: getmntent() returns wrong default value for fs_passno naszar at ya dot ru
2014-08-15 3:53 ` [Bug libc/17273] " naszar at ya dot ru
2014-08-15 3:54 ` naszar at ya dot ru
2015-08-28 20:34 ` vapier at gentoo dot org
2015-08-28 20:36 ` vapier at gentoo dot org
2015-08-29 22:11 ` cvs-commit at gcc dot gnu.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
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).