helper/command: clear errno before calling parser 98/5298/2
authorChristopher Head <chead@zaber.com>
Mon, 9 Sep 2019 20:52:51 +0000 (13:52 -0700)
committerTomas Vanek <vanekt@fbl.cz>
Tue, 24 Sep 2019 04:47:18 +0000 (05:47 +0100)
The C standard says that errno is set to ERANGE if an out-of-range value
is returned by strtol, strtoul, et. al., but it does not say that errno
is cleared if the function is successful (and, indeed, it is not on
glibc). This means that, if errno is ERANGE before strtol is called, and
if the value to be converted is exactly the maximum (or, for a signed
conversion, the minimum) legal value, COMMAND_PARSE_NUMBER will
erroneously indicate that the value is out of range.

Change-Id: I8a8b50a815b408a38235968f1c1d70297ea1a6aa
Signed-off-by: Christopher Head <chead@zaber.com>
Reviewed-on: http://openocd.zylin.com/5298
Tested-by: jenkins
Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/helper/command.c

index 7b93df6e114408fb5e05513d8a502681a87ae4b6..d969933e2dba0bc9c8f8c554c83def7c97c9d20b 100644 (file)
@@ -1394,6 +1394,7 @@ void process_jim_events(struct command_context *cmd_ctx)
                        return ERROR_COMMAND_ARGUMENT_INVALID; \
                } \
                char *end; \
                        return ERROR_COMMAND_ARGUMENT_INVALID; \
                } \
                char *end; \
+               errno = 0; \
                *ul = func(str, &end, 0); \
                if (*end) { \
                        LOG_ERROR("Invalid command argument"); \
                *ul = func(str, &end, 0); \
                if (*end) { \
                        LOG_ERROR("Invalid command argument"); \

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)