From 61531451f2d65a62fe7648bba621e1600f69f997 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 3 Nov 2016 12:55:44 +0100 Subject: [PATCH] examples: fix off-by-one error in TinyDTLS example --- examples/dtls-echo/dtls-client.c | 13 ++++--------- examples/dtls-echo/dtls-server.c | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/dtls-echo/dtls-client.c b/examples/dtls-echo/dtls-client.c index bef48c3646..f0a0b356d2 100644 --- a/examples/dtls-echo/dtls-client.c +++ b/examples/dtls-echo/dtls-client.c @@ -502,18 +502,13 @@ static void client_send(char *addr_str, char *data, unsigned int delay) int udp_client_cmd(int argc, char **argv) { - if (argc < 2) { + uint32_t delay = 1000000; + + if (argc < 3) { printf("usage: %s []\n", argv[0]); return 1; } - - uint32_t delay = 1000000; - if (argc < 3) { - printf("usage: %s []\n", - argv[0]); - return 1; - } - if (argc > 3) { + else if (argc > 3) { delay = (uint32_t)atoi(argv[3]); } client_send(argv[1], argv[2], delay); diff --git a/examples/dtls-echo/dtls-server.c b/examples/dtls-echo/dtls-server.c index 2156f76166..bbec858e11 100644 --- a/examples/dtls-echo/dtls-server.c +++ b/examples/dtls-echo/dtls-server.c @@ -435,7 +435,7 @@ static void stop_server(void) int udp_server_cmd(int argc, char **argv) { - if (argc < 1) { + if (argc < 2) { printf("usage: %s start|stop\n", argv[0]); return 1; }