lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1473301617-9123-1-git-send-email-liuhangbin@gmail.com>
Date:   Thu,  8 Sep 2016 10:26:57 +0800
From:   Hangbin Liu <liuhangbin@...il.com>
To:     netdev@...r.kernel.org
Cc:     David Laight <David.Laight@...LAB.COM>, Phil Sutter <phil@....cc>,
        Stephen Hemminger <stephen@...workplumber.org>,
        Hangbin Liu <liuhangbin@...il.com>
Subject: [PATCHv2 iproute2] ip route: check ftell, fseek return value

ftell() may return -1 in error case, which is not handled and therefore pass a
negative offset to fseek(). The return code of fseek() is also not checked.

Reported-by: Phil Sutter <phil@....cc>
Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
---
 ip/iproute.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/ip/iproute.c b/ip/iproute.c
index 3da23af..c06a474 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -1860,6 +1860,11 @@ static int iproute_restore(void)
 		exit(-1);
 
 	pos = ftell(stdin);
+	if (pos == -1) {
+		perror("Failed to restore: ftell");
+		exit(-1);
+	}
+
 	for (prio = 0; prio < 3; prio++) {
 		int err;
 
@@ -1867,7 +1872,10 @@ static int iproute_restore(void)
 		if (err)
 			exit(err);
 
-		fseek(stdin, pos, SEEK_SET);
+		if (fseek(stdin, pos, SEEK_SET) == -1) {
+			perror("Failed to restore: fseek");
+			exit(-1);
+		}
 	}
 
 	exit(0);
-- 
2.5.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ