[Git][NTPsec/ntpsec][master] 2 commits: CID 306369: Remove logically dead code.
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Sep 1 20:12:37 UTC 2020
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
c5271609 by Eric S. Raymond at 2020-09-01T16:13:48-04:00
CID 306369: Remove logically dead code.
peer == NULL was excluded back on line 733.
- - - - -
4841068a by Eric S. Raymond at 2020-09-01T16:13:48-04:00
Code ckeanups that fix three Coverity issues.
- - - - -
4 changed files:
- libntp/authreadkeys.c
- libntp/pymodule-mac.c
- ntpd/ntp_proto.c
- tests/unity/unity_memory.c
Changes:
=====================================
libntp/authreadkeys.c
=====================================
@@ -132,7 +132,14 @@ check_cmac_mac_length(
const EVP_CIPHER *cmac_cipher = EVP_get_cipherbyname(name);
ctx = CMAC_CTX_new();
- CMAC_Init(ctx, key, EVP_CIPHER_key_length(cmac_cipher), cmac_cipher, NULL);
+ if (!CMAC_Init(ctx, key, EVP_CIPHER_key_length(cmac_cipher), cmac_cipher, NULL)) {
+ /* Shouldnv't happen. */
+ msyslog(LOG_ERR,
+ "CMAC: encrypt: CMAC init failed during MAC length check");
+ return;
+ }
+
+
CMAC_Final(ctx, mac, &length);
CMAC_CTX_free(ctx);
=====================================
libntp/pymodule-mac.c
=====================================
@@ -92,6 +92,7 @@ void do_mac(char *name,
const EVP_MD *digest;
const EVP_CIPHER *cipher;
size_t cipherlen;
+ uint8_t newkey[EVP_MAX_KEY_LENGTH];
SSL_init();
@@ -134,7 +135,6 @@ void do_mac(char *name,
if (cipherlen < keylen) {
keylen = cipherlen; /* truncate */
} else if (cipherlen > keylen) {
- uint8_t newkey[EVP_MAX_KEY_LENGTH];
memcpy(newkey, key, keylen);
while (cipherlen > keylen)
key[keylen++] = 0; /* pad with 0s */
=====================================
ntpd/ntp_proto.c
=====================================
@@ -788,10 +788,6 @@ receive(
stat_count.sys_processed++;
break;
case MODE_SERVER: /* Reply to our request to a server. */
- if (NULL == peer) {
- stat_count.sys_declined++;
- break;
- }
if ((peer->cfg.flags & FLAG_NTS)
&& (!rbufp->extens_present
#ifndef DISABLE_NTS
=====================================
tests/unity/unity_memory.c
=====================================
@@ -179,8 +179,9 @@ void* unity_realloc(void* oldMem, size_t size)
release_memory(oldMem);
return NULL;
}
-
- if (guard->size >= size) return oldMem;
+ else if (guard->size >= size) {
+ return oldMem;
+ }
#ifdef UNITY_EXCLUDE_STDLIB_MALLOC /* Optimization if memory is expandable */
{
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/2219f1f66b3b260ff3133126429d6a6b444303c7...4841068a2d7fa0cdaded22b8924d4a8e75d09cbc
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/2219f1f66b3b260ff3133126429d6a6b444303c7...4841068a2d7fa0cdaded22b8924d4a8e75d09cbc
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/20200901/bd782806/attachment-0001.htm>
More information about the vc
mailing list