package apt-cacher-ng
tags 502072 patch
thanks

Using strtol() with appropriate check instead of atoi() should cope with
the error better, without false alarm. (See the proposed patch.)

-- 
Theppitak Karoonboonyanan
http://linux.thai.net/~thep/
Index: apt-cacher-ng-0.3.1/source/acfg.cc
===================================================================
--- apt-cacher-ng-0.3.1.orig/source/acfg.cc	2008-10-13 19:19:28.000000000 +0700
+++ apt-cacher-ng-0.3.1/source/acfg.cc	2008-10-13 19:19:53.000000000 +0700
@@ -16,6 +16,8 @@
 #include <glob.h>
 #endif
 
+#include <errno.h>
+
 #include <iostream>
 #include <fstream>
 #include <string>
@@ -234,8 +236,9 @@
 		*sTarget=value;
 	else if ( NULL != (nTarget = _GetIntPtr(key)))
 	{
-		*nTarget=atoi(value.c_str());
-		if(0==*nTarget)
+		char *pEnd;
+		*nTarget=strtol(value.c_str(), &pEnd, 10);
+		if(*pEnd || errno == EINVAL || errno == ERANGE)
 		{
 			if(value.length()<1)
 				cerr << "Unexpected empty value for " << key << ", check the configuration!"<<endl;

Attachment: signature.asc
Description: Digital signature

Reply via email to