#include <hallo.h>
* Theppitak Karoonboonyanan [Mon, Oct 13 2008, 07:27:32PM]:
> 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.)
Indeed, thanks. But please read the manpage carefully, i.e. this part:
Since strtol() can legitimately return 0, LONG_MAX, or LONG_MIN
(LLONG_MAX or LLONG_MIN for strtoll()) on both success and
failure, the calling program should set errno to 0 before the
call, and then determine if an error occurred by checking whether
errno has a non-zero value after the call.
Regarsd,
Eduard.
>
> --
> 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;
--
Programmierer, die nur dann nicht chaotisch programmieren,
wenn sie die Sprache dazu zwingt, nicht chaotisch zu
programmieren, sind schlechte Programmierer.
-- 1. Satz des Sesom
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]