From 186ea0e203a9db5742957a7ba5f1e442445525d7 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Sun, 8 Mar 2009 20:21:24 +0000 Subject: [PATCH] * libmisc/getlong.c: Make sure the getlong argument is not empty. --- ChangeLog | 4 ++++ libmisc/getlong.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 566937ca..efa98c80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-03-07 Nicolas François + + * libmisc/getlong.c: Make sure the getlong argument is not empty. + 2009-03-07 Nicolas François * contrib/adduser-old.c, contrib/adduser.c: Do not use the target diff --git a/libmisc/getlong.c b/libmisc/getlong.c index 7c3d2ce0..48914b37 100644 --- a/libmisc/getlong.c +++ b/libmisc/getlong.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 - 2008, Nicolas François + * Copyright (c) 2007 - 2009, Nicolas François * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,14 +34,14 @@ #include "prototypes.h" #include "defines.h" -int getlong(const char *numstr, long int *result) +int getlong (const char *numstr, long int *result) { long val; char *endptr; errno = 0; val = strtol (numstr, &endptr, 10); - if (('\0' != *endptr) || (ERANGE == errno)) { + if (('\0' == numstr) || ('\0' != *endptr) || (ERANGE == errno)) { return 0; } -- 2.40.0