* [PATCH] sulogin: Use read instead of allocated size from getline()
@ 2015-06-06 4:26 Guillem Jover
2015-06-08 10:22 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Guillem Jover @ 2015-06-06 4:26 UTC (permalink / raw)
To: util-linux
The getline function distinguishes between the allocated and read
lenghts, and we should not mix them up, as we might end up processing
junk.
Signed-off-by: Guillem Jover <guillem@hadrons.org>
---
login-utils/sulogin-consoles.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/login-utils/sulogin-consoles.c b/login-utils/sulogin-consoles.c
index 9fd1034..39d24d2 100644
--- a/login-utils/sulogin-consoles.c
+++ b/login-utils/sulogin-consoles.c
@@ -154,13 +154,15 @@ char *oneline(const char *file)
{
FILE *fp;
char *ret = NULL;
- size_t len = 0;
+ size_t dummy = 0;
+ ssize_t len;
DBG(dbgprint("reading %s", file));
if (!(fp = fopen(file, "re")))
return NULL;
- if (getline(&ret, &len, fp) >= 0) {
+ len = getline(&ret, &dummy, fp);
+ if (len >= 0) {
char *nl;
if (len)
--
2.2.1.209.g41e5f3a
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sulogin: Use read instead of allocated size from getline()
2015-06-06 4:26 [PATCH] sulogin: Use read instead of allocated size from getline() Guillem Jover
@ 2015-06-08 10:22 ` Karel Zak
0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-06-08 10:22 UTC (permalink / raw)
To: Guillem Jover; +Cc: util-linux
On Sat, Jun 06, 2015 at 06:26:43AM +0200, Guillem Jover wrote:
> login-utils/sulogin-consoles.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Applied, thanks.
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-08 10:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-06 4:26 [PATCH] sulogin: Use read instead of allocated size from getline() Guillem Jover
2015-06-08 10:22 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox