From a7802e9a763665b5fc0404e27ce0ce99d30bb038 Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 9 Jan 2017 13:43:26 +0100 Subject: [PATCH] fix some coverity warnings --- client.c | 6 ++++-- main.c | 3 ++- sys_timex.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client.c b/client.c index dbc9d6f..c6e44b3 100644 --- a/client.c +++ b/client.c @@ -2723,7 +2723,8 @@ process_cmd_waitsync(char *line) max_skew_ppm = 0.0; interval = 10.0; - sscanf(line, "%d %lf %lf %lf", &max_tries, &max_correction, &max_skew_ppm, &interval); + if (sscanf(line, "%d %lf %lf %lf", &max_tries, &max_correction, &max_skew_ppm, &interval)) + ; /* Don't allow shorter interval than 0.1 seconds */ if (interval < 0.1) @@ -2831,7 +2832,8 @@ process_cmd_keygen(char *line) snprintf(hash_name, sizeof (hash_name), "MD5"); #endif - sscanf(line, "%u %16s %d", &id, hash_name, &bits); + if (sscanf(line, "%u %16s %d", &id, hash_name, &bits)) + ; length = CLAMP(10, (bits + 7) / 8, sizeof (key)); if (HSH_GetHashId(hash_name) < 0) { diff --git a/main.c b/main.c index aaa8744..2f29358 100644 --- a/main.c +++ b/main.c @@ -325,7 +325,8 @@ go_daemon(void) if (r) { if (r > 0) { /* Print the error message from the child */ - fprintf(stderr, "%.1024s\n", message); + message[sizeof (message) - 1] = '\0'; + fprintf(stderr, "%s\n", message); } exit(1); } else diff --git a/sys_timex.c b/sys_timex.c index 7abb629..4ec4ce8 100644 --- a/sys_timex.c +++ b/sys_timex.c @@ -158,7 +158,8 @@ set_sync_status(int synchronised, double est_error, double max_error) txc.esterror = est_error * 1.0e6; txc.maxerror = max_error * 1.0e6; - SYS_Timex_Adjust(&txc, 1); + if (SYS_Timex_Adjust(&txc, 1) < 0) + ; } /* ================================================== */