diff options
author | Martin Ejdestig <martin.ejdestig@volvocars.com> | 2020-11-17 01:21:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 09:21:54 +0900 |
commit | 16ab307eca98a49d66bf3332578b4bdd32f63732 (patch) | |
tree | 608cf4bd1b1609602b2bd4b6a14599758e74ee90 /src/examples/dlt-example-user.c | |
parent | d02ef27da01149f2b3da9de3efea85504afeecfa (diff) | |
download | DLT-daemon-16ab307eca98a49d66bf3332578b4bdd32f63732.tar.gz |
Fix overflow for -d argument in dlt-example-user (#270)
atoi(dvalue) * 1000000 overflows if given a value >= 2147 when
sizeof(int) is 4. (2^31 / 10000000 ~= 2147.48)
Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
Diffstat (limited to 'src/examples/dlt-example-user.c')
-rw-r--r-- | src/examples/dlt-example-user.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/examples/dlt-example-user.c b/src/examples/dlt-example-user.c index db177ef..fabb1d7 100644 --- a/src/examples/dlt-example-user.c +++ b/src/examples/dlt-example-user.c @@ -310,9 +310,9 @@ int main(int argc, char *argv[]) maxnum = 10; if (dvalue) - delay = atoi(dvalue) * 1000000; + delay = atoi(dvalue); else - delay = 500 * 1000000; + delay = 500; if (tvalue) dlt_set_resend_timeout_atexit(atoi(tvalue)); @@ -378,8 +378,8 @@ int main(int argc, char *argv[]) } if (delay > 0) { - ts.tv_sec = delay / 1000000000; - ts.tv_nsec = delay % 1000000000; + ts.tv_sec = delay / 1000; + ts.tv_nsec = (delay % 1000) * 1000000; nanosleep(&ts, NULL); } } |