From 7a609401b7b1eb53e35c3203c28c233d0b4a00cc Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 27 Nov 2015 06:53:47 +0100 Subject: restricted-hdparm: sanity check argc, and report failure of setuid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/restricted-hdparm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/restricted-hdparm.c') diff --git a/src/restricted-hdparm.c b/src/restricted-hdparm.c index 2b2e0f0..4c8bc3b 100644 --- a/src/restricted-hdparm.c +++ b/src/restricted-hdparm.c @@ -22,10 +22,16 @@ int main(int argc, char** argv) { - char* act = argv[1]; + char* act; int i; - setuid(0); + if (argc < 2) + return 1; + + if (setuid(0)) + perror(*argv); + + act = argv[1]; for (i = 2; i < argc; i++) if (argv[i][0] == '/') -- cgit v1.2.3-70-g09d2