On 2017-11-02 12:54, Andreas Reichel wrote:
> On Fri, Oct 20, 2017 at 01:11:51PM +0200, Andreas J. Reichel wrote:
> Can we please apply this patch now? [ This is 3/3 ]
> 

Thanks, also applied to next.

Jan

>> From: Andreas Reichel <[email protected]>
>>
>> If errno is not set to zero before strtol is called, one cannot
>> distinguish between a successful conversion of "0" and a real error,
>> because errno might have already been set before the call to strtol but
>> strtol itself does not set errno to zero.
>>
>> Signed-off-by: Andreas Reichel <[email protected]>
>> ---
>>  env/env_api_fat.c | 3 +++
>>  tools/bg_setenv.c | 2 ++
>>  2 files changed, 5 insertions(+)
>>
>> diff --git a/env/env_api_fat.c b/env/env_api_fat.c
>> index 851b70c..653d3f8 100644
>> --- a/env/env_api_fat.c
>> +++ b/env/env_api_fat.c
>> @@ -552,6 +552,7 @@ int bgenv_set(BGENV *env, char *key, char *type, void 
>> *data, uint32_t datalen)
>>      }
>>      switch (e) {
>>      case EBGENV_REVISION:
>> +            errno = 0;
>>              val = strtol(value, &p, 10);
>>              if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) ||
>>                  (errno != 0 && val == 0)) {
>> @@ -569,6 +570,7 @@ int bgenv_set(BGENV *env, char *key, char *type, void 
>> *data, uint32_t datalen)
>>              str8to16(env->data->kernelparams, value);
>>              break;
>>      case EBGENV_WATCHDOG_TIMEOUT_SEC:
>> +            errno = 0;
>>              val = strtol(value, &p, 10);
>>              if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) ||
>>                  (errno != 0 && val == 0)) {
>> @@ -580,6 +582,7 @@ int bgenv_set(BGENV *env, char *key, char *type, void 
>> *data, uint32_t datalen)
>>              env->data->watchdog_timeout_sec = val;
>>              break;
>>      case EBGENV_USTATE:
>> +            errno = 0;
>>              val = strtol(value, &p, 10);
>>              if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) ||
>>                  (errno != 0 && val == 0)) {
>> diff --git a/tools/bg_setenv.c b/tools/bg_setenv.c
>> index 3afcc9f..8aa6668 100644
>> --- a/tools/bg_setenv.c
>> +++ b/tools/bg_setenv.c
>> @@ -244,6 +244,7 @@ static error_t parse_opt(int key, char *arg, struct 
>> argp_state *state)
>>                                     (uint8_t *)arg, strlen(arg) + 1);
>>              break;
>>      case 'p':
>> +            errno = 0;
>>              i = strtol(arg, &tmp, 10);
>>              if ((errno == ERANGE && (i == LONG_MAX || i == LONG_MIN)) ||
>>                  (errno != 0 && i == 0) || (tmp == arg)) {
>> @@ -262,6 +263,7 @@ static error_t parse_opt(int key, char *arg, struct 
>> argp_state *state)
>>              }
>>              break;
>>      case 's':
>> +            errno = 0;
>>              i = strtol(arg, &tmp, 10);
>>              if ((errno == ERANGE && (i == LONG_MAX || i == LONG_MIN)) ||
>>                  (errno != 0 && i == 0) || (tmp == arg)) {
>> -- 
>> 2.14.2
>>
> 

-- 
Siemens AG, Corporate Technology, CT RDA ITP SES-DE
Corporate Competence Center Embedded Linux

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/b3a23102-75a2-8896-c943-f9de43c3e5a6%40siemens.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to