[Git][NTPsec/ntpsec][master] 7 commits: ntp_monitor: add comment about why coverity warning is ignored.
Gary E. Miller
gitlab at mg.gitlab.com
Fri May 26 03:03:49 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
2a000521 by Gary E. Miller at 2017-05-25T17:54:03-07:00
ntp_monitor: add comment about why coverity warning is ignored.
- - - - -
929e44cd by Gary E. Miller at 2017-05-25T19:01:15-07:00
refclock_oncore: another attempt to fix a coverity warning.
For some things coverity only reports the first instance found.
- - - - -
f91a9e2c by Gary E. Miller at 2017-05-25T19:08:49-07:00
add comments about coverity toctou errors.
No real way to fix these warnings, and no real bad issue if the tiny
races fail.
- - - - -
335ae179 by Gary E. Miller at 2017-05-25T19:26:29-07:00
ntp_config: make check_netinfo static
- - - - -
b405d02f by Gary E. Miller at 2017-05-25T19:30:50-07:00
ntpd: make 3 functions static.
- - - - -
afda933a by Gary E. Miller at 2017-05-25T19:55:55-07:00
ntp_config: make config_netinfo static.
- - - - -
709a3e71 by Gary E. Miller at 2017-05-25T20:02:50-07:00
old_config_style was always true, eliminate the variable.
- - - - -
8 changed files:
- ntpd/ntp_config.c
- ntpd/ntp_filegen.c
- ntpd/ntp_leapsec.c
- ntpd/ntp_monitor.c
- ntpd/ntp_scanner.c
- ntpd/ntp_scanner.h
- ntpd/ntpd.c
- ntpd/refclock_oncore.c
Changes:
=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -166,8 +166,8 @@ static char default_ntp_signd_socket[] =
#endif
char *ntp_signd_socket = default_ntp_signd_socket;
#ifdef HAVE_NETINFO_NI_H
-struct netinfo_config_state *config_netinfo = NULL;
-bool check_netinfo = true;
+static struct netinfo_config_state *config_netinfo = NULL;
+static bool check_netinfo = true;
#endif /* HAVE_NETINFO_NI_H */
#ifdef HAVE_NETINFO_NI_H
@@ -185,12 +185,6 @@ struct netinfo_config_state {
struct REMOTE_CONFIG_INFO remote_config; /* Remote configuration buffer and
pointer info */
-bool old_config_style = true; /* A boolean flag, which when set,
- * indicates that the old configuration
- * format with a newline at the end of
- * every command is being used
- */
-
/* FUNCTION PROTOTYPES */
static void init_syntax_tree(config_tree *);
=====================================
ntpd/ntp_filegen.c
=====================================
--- a/ntpd/ntp_filegen.c
+++ b/ntpd/ntp_filegen.c
@@ -212,6 +212,7 @@ filegen_open(
#ifndef S_ISREG
#define S_ISREG(mode) (((mode) & S_IFREG) == S_IFREG)
#endif
+ /* coverity[toctou] */
if (stat(filename, &stats) == 0) {
/* Hm, file exists... */
if (S_ISREG(stats.st_mode)) {
=====================================
ntpd/ntp_leapsec.c
=====================================
--- a/ntpd/ntp_leapsec.c
+++ b/ntpd/ntp_leapsec.c
@@ -459,6 +459,7 @@ leapsec_load_file(
return false;
/* try to stat the leapfile */
+ /* coverity[toctou] */
if (0 != stat(fname, &sb_new)) {
if (logall)
msyslog(LOG_ERR, "%s ('%s'): stat failed: %m",
=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -186,6 +186,7 @@ mon_getmoremem(void)
mon_mem_increments++;
}
+ /* chunk not free()ed, chunk added to free list */
/* coverity[leaked_storage] */
}
=====================================
ntpd/ntp_scanner.c
=====================================
--- a/ntpd/ntp_scanner.c
+++ b/ntpd/ntp_scanner.c
@@ -45,8 +45,6 @@ static uint32_t conf_file_sum; /* Simple sum of characters read */
static struct FILE_INFO * lex_stack = NULL;
-
-
/* CONSTANTS AND MACROS
* --------------------
*/
@@ -698,8 +696,7 @@ is_EOC(
int ch
)
{
- if ((old_config_style && (ch == '\n')) ||
- (!old_config_style && (ch == ';')))
+ if ( ch == '\n')
return true;
return false;
}
@@ -801,7 +798,7 @@ yylex(void)
* a single string following as in:
* setvar Owner = "The Boss" default
*/
- if ('=' == ch && old_config_style)
+ if ('=' == ch )
followedby = FOLLBY_STRING;
yytext[0] = (char)ch;
yytext[1] = '\0';
@@ -880,16 +877,6 @@ yylex(void)
if (followedby == FOLLBY_TOKEN && !instring) {
token = is_keyword(yytext, &followedby);
if (token) {
- /*
- * T_Server is exceptional as it forces the
- * following token to be a string in the
- * non-simulator parts of the configuration,
- * but in the simulator configuration section,
- * "server" is followed by "=" which must be
- * recognized as a token not a string.
- */
- if (T_Server == token && !old_config_style)
- followedby = FOLLBY_TOKEN;
goto normal_return;
} else if (is_integer(yytext)) {
yylval_was_set = true;
=====================================
ntpd/ntp_scanner.h
=====================================
--- a/ntpd/ntp_scanner.h
+++ b/ntpd/ntp_scanner.h
@@ -114,11 +114,6 @@ struct FILE_INFO {
*/
extern config_tree cfgt; /* Parser output stored here */
-/* VARIOUS EXTERNAL DECLARATIONS
- * -----------------------------
- */
-extern bool old_config_style;
-
/* VARIOUS SUBROUTINE DECLARATIONS
* -------------------------------
*/
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -89,10 +89,6 @@ int waitsync_fd_to_close = -1; /* -w/--wait-sync */
const char *progname;
-#ifdef HAVE_NETINFO_NI_H
-extern bool check_netinfo;
-#endif
-
#if defined(HAVE_WORKING_FORK)
static int wait_child_sync_if (int, long);
#endif
@@ -112,7 +108,7 @@ static void no_debug (int);
static int saved_argc;
static char ** saved_argv;
-int ntpdmain(int, char **) __attribute__((noreturn));
+static int ntpdmain(int, char **) __attribute__((noreturn));
static void mainloop (void)
__attribute__ ((__noreturn__));
static void set_process_priority (void);
@@ -128,8 +124,8 @@ static void library_unexpected_error(const char *, int,
const char *, va_list)
ISC_FORMAT_PRINTF(3, 0);
-extern void close_all_beyond(int);
-extern void close_all_except(int);
+static void close_all_beyond(int);
+static void close_all_except(int);
#define ALL_OPTIONS "46bc:dD:f:gGhi:I:k:l:LmnNp:Pqr:Rs:t:u:U:Vw:xzZ"
@@ -498,7 +494,7 @@ const char *ntpd_version(void)
* Main program. Initialize us, disconnect us from the tty if necessary,
* and loop waiting for I/O and/or timer expiries.
*/
-int
+static int
ntpdmain(
int argc,
char *argv[]
@@ -1347,7 +1343,7 @@ no_debug(
*
* Close all file descriptors except the given keep_fd.
*/
-void
+static void
close_all_except(
int keep_fd
)
@@ -1369,7 +1365,7 @@ close_all_except(
*
* http://stackoverflow.com/questions/899038/getting-the-highest-allocated-file-descriptor
*/
-void
+static void
close_all_beyond(
int keep_fd
)
=====================================
ntpd/refclock_oncore.c
=====================================
--- a/ntpd/refclock_oncore.c
+++ b/ntpd/refclock_oncore.c
@@ -670,6 +670,7 @@ oncore_start(
return false; /* exit, can't open file, can't start driver */
}
+ /* coverity[toctou] */
if (stat(device2, &stat2)) {
stat2.st_dev = stat2.st_ino = (ino_t)-2;
oncore_log_f(instance, LOG_ERR, "Can't stat fd2 (%s) %d %m",
@@ -1278,7 +1279,8 @@ oncore_read_config(
if (!strncmp(cc, "LAT", (size_t) 3)) {
f1 = f2 = f3 = 0;
- sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3);
+ if ( 3 != sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3))
+ continue;
sign = 1;
if (f1 < 0) {
f1 = -f1;
@@ -1288,7 +1290,8 @@ oncore_read_config(
lat_flg++;
} else if (!strncmp(cc, "LON", (size_t) 3)) {
f1 = f2 = f3 = 0;
- sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3);
+ if ( 3 != sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3))
+ continue;
sign = 1;
if (f1 < 0) {
f1 = -f1;
@@ -1299,7 +1302,8 @@ oncore_read_config(
} else if (!strncmp(cc, "HT", (size_t) 2)) {
f1 = 0;
units[0] = '\0';
- sscanf(ca, "%lf %1s", &f1, units);
+ if ( 2 != sscanf(ca, "%lf %1s", &f1, units))
+ continue;
if (units[0] == 'F')
f1 = 0.3048 * f1;
instance->ss_ht = 100 * f1; /* cm */
@@ -1307,7 +1311,8 @@ oncore_read_config(
} else if (!strncmp(cc, "DELAY", (size_t) 5)) {
f1 = 0;
units[0] = '\0';
- sscanf(ca, "%lf %1s", &f1, units);
+ if ( 2 != sscanf(ca, "%lf %1s", &f1, units))
+ continue;
if (units[0] == 'N')
;
else if (units[0] == 'U')
@@ -1327,7 +1332,8 @@ oncore_read_config(
} else if (!strncmp(cc, "OFFSET", (size_t) 6)) {
f1 = 0;
units[0] = '\0';
- sscanf(ca, "%lf %1s", &f1, units);
+ if ( 2 != sscanf(ca, "%lf %1s", &f1, units))
+ continue;
if (units[0] == 'N')
;
else if (units[0] == 'U')
@@ -1345,7 +1351,8 @@ oncore_read_config(
else
instance->offset = f1; /* offset in ns */
} else if (!strncmp(cc, "MODE", (size_t) 4)) {
- sscanf(ca, "%d", &mode);
+ if ( 1 != sscanf(ca, "%d", &mode))
+ continue;
if (mode < 0 || mode > 4)
mode = 4;
} else if (!strncmp(cc, "ASSERT", (size_t) 6)) {
@@ -1359,7 +1366,8 @@ oncore_read_config(
} else if (!strncmp(cc, "POSN3D", (size_t) 6)) {
instance->shmem_Posn = 3;
} else if (!strncmp(cc, "CHAN", (size_t) 4)) {
- sscanf(ca, "%d", &i);
+ if ( 1 != sscanf(ca, "%d", &i))
+ continue;
if ((i == 6) || (i == 8) || (i == 12))
instance->chan_in = i;
} else if (!strncmp(cc, "TRAIM", (size_t) 5)) {
@@ -1368,7 +1376,7 @@ oncore_read_config(
instance->traim_in = 0;
} else if (!strncmp(cc, "MASK", (size_t) 4)) {
if ( 1 != sscanf(ca, "%d", &mask) )
- mask = -1;
+ continue;
if (mask > -1 && mask < 90)
instance->Ag = mask; /* Satellite mask angle */
} else if (!strncmp(cc,"PPSCONTROL",10)) { /* pps control M12 only */
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/facf8d7c163e58ff6015d0552fc3bda86a918bb0...709a3e71f0b152db024b20680da643628935a130
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/facf8d7c163e58ff6015d0552fc3bda86a918bb0...709a3e71f0b152db024b20680da643628935a130
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170526/f4add175/attachment.html>
More information about the vc
mailing list