From db932574059069ddb8b3fe2b8c06ca854fff7342 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sat, 27 Aug 2011 20:57:18 +0000 Subject: check errno after calls to strtol() to ensure that numbers that are too large for type will be reported (thanks Jakub Hrozek) git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1523 ef36b2f9-881f-0410-afb5-c4e39611909c --- nslcd/service.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nslcd/service.c') diff --git a/nslcd/service.c b/nslcd/service.c index 3c487f7..4a43022 100644 --- a/nslcd/service.c +++ b/nslcd/service.c @@ -5,7 +5,7 @@ Copyright (C) 1997-2005 Luke Howard Copyright (C) 2006 West Consulting - Copyright (C) 2006, 2007, 2009, 2010 Arthur de Jong + Copyright (C) 2006, 2007, 2009, 2010, 2011 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -172,6 +172,7 @@ static int write_service(TFILE *fp,MYLDAP_ENTRY *entry, log_log(LOG_WARNING,"service entry %s contains multiple %s values", myldap_get_dn(entry),attmap_service_ipServicePort); } + errno=0; port=(int)strtol(ports[0],&tmp,0); if ((*(ports[0])=='\0')||(*tmp!='\0')) { @@ -179,6 +180,12 @@ static int write_service(TFILE *fp,MYLDAP_ENTRY *entry, myldap_get_dn(entry),attmap_service_ipServicePort); return 0; } + else if (errno!=0) + { + log_log(LOG_WARNING,"service entry %s contains too large %s value", + myldap_get_dn(entry),attmap_service_ipServicePort); + return 0; + } /* get protocols */ protocols=myldap_get_values(entry,attmap_service_ipServiceProtocol); if ((protocols==NULL)||(protocols[0]==NULL)) -- cgit v1.2.3