cmdparse: don't allow NTP key ID of 0

Key number 0 is used as inactive key, prevent the user from
inadvertently not using authentication.
This commit is contained in:
Miroslav Lichvar
2014-03-21 12:47:52 +01:00
parent 6560628209
commit 6c2a1e62e0
2 changed files with 6 additions and 3 deletions

View File

@@ -134,7 +134,8 @@ CPS_ParseNTPSourceAdd(char *line, CPS_NTP_Source *src)
line += n;
}
} else if (!strcasecmp(cmd, "key")) {
if (sscanf(line, "%lu%n", &src->params.authkey, &n) != 1) {
if (sscanf(line, "%lu%n", &src->params.authkey, &n) != 1 ||
src->params.authkey == INACTIVE_AUTHKEY) {
result = CPS_BadKey;
ok = 0;
done = 1;