---
+
+* [Bug 1581] size_t printf format string mismatches, IRIG string buffers
+ undersized. Mostly backported from earlier ntp-dev fixes by Jürgen
+ Perlinger.
+
+---
(4.2.6p2-RC7) 2010/06/19 Released by Harlan Stenn <stenn@ntp.org>
* [Bug 1570] serial clock drivers get outdated input from kernel tty
size_t *pdigest_len
)
{
+ const u_long max_digest_len = MAX_MAC_LEN - sizeof(keyid_t);
int key_type;
u_int digest_len;
#ifdef OPENSSL
EVP_DigestFinal(&ctx, digest, &digest_len);
if (digest_len + sizeof(keyid_t) > MAX_MAC_LEN) {
fprintf(stderr,
- "key type %s %u octet digests are too big, max %u\n",
+ "key type %s %u octet digests are too big, max %lu\n",
keytype_name(key_type), digest_len,
- MAX_MAC_LEN - sizeof(keyid_t));
+ max_digest_len);
msyslog(LOG_ERR,
- "key type %s %u octet digests are too big, max %u",
+ "key type %s %u octet digests are too big, max %lu\n",
keytype_name(key_type), digest_len,
- MAX_MAC_LEN - sizeof(keyid_t));
+ max_digest_len);
return 0;
}
#else
sys_phone[i++] = estrdup(*s);
else
msyslog(LOG_INFO,
- "phone: Number of phone entries exceeds %d. Ignoring phone %s...",
- COUNTOF(sys_phone) - 1, *s);
+ "phone: Number of phone entries exceeds %lu. Ignoring phone %s...",
+ (u_long)(COUNTOF(sys_phone) - 1), *s);
s = next_node(s);
}
sys_ttl[i++] = (u_char)*curr_ttl;
else
msyslog(LOG_INFO,
- "ttl: Number of TTL entries exceeds %d. Ignoring TTL %d...",
- COUNTOF(sys_ttl), *curr_ttl);
+ "ttl: Number of TTL entries exceeds %lu. Ignoring TTL %d...",
+ (u_long)COUNTOF(sys_ttl), *curr_ttl);
curr_ttl = next_node(curr_ttl);
}
total_len = pchEnd - (char *)&reqpkt;
if (total_len > sizeof(reqpkt)) {
msyslog(LOG_ERR,
- "intres total_len %u limit is %u (%u octet digest)\n",
- total_len, sizeof(reqpkt),
- req_hashlen);
+ "intres total_len %lu limit is %lu (%lu octet digest)\n",
+ (u_long)total_len,
+ (u_long)sizeof(reqpkt),
+ (u_long)req_hashlen);
resolver_exit(1);
}
} else {
if ((size_t)n != req_hashlen + sizeof(reqpkt.keyid)) {
msyslog(LOG_ERR,
"intres maclen %d expected %u\n",
- n, req_hashlen + sizeof(reqpkt.keyid));
+ n, (u_long)(req_hashlen +
+ sizeof(reqpkt.keyid)));
resolver_exit(1);
}
req_len += n;
*/
if (!INFO_IS_AUTH(inpkt->auth_seq) || !info_auth_keyid
|| ntohl(tailinpkt->keyid) != info_auth_keyid) {
- DPRINTF(5, ("failed auth %d info_auth_keyid %u pkt keyid %u maclen %u\n",
+ DPRINTF(5, ("failed auth %d info_auth_keyid %u pkt keyid %u maclen %lu\n",
INFO_IS_AUTH(inpkt->auth_seq),
info_auth_keyid,
- ntohl(tailinpkt->keyid), mac_len));
+ ntohl(tailinpkt->keyid), (u_long)mac_len));
#ifdef DEBUG
msyslog(LOG_DEBUG,
- "process_private: failed auth %d info_auth_keyid %u pkt keyid %u maclen %u\n",
+ "process_private: failed auth %d info_auth_keyid %u pkt keyid %u maclen %lu\n",
INFO_IS_AUTH(inpkt->auth_seq),
info_auth_keyid,
- ntohl(tailinpkt->keyid), mac_len);
+ ntohl(tailinpkt->keyid), (u_long)mac_len);
#endif
req_ack(srcadr, inter, inpkt, INFO_ERR_AUTH);
return;
}
if (recv_len > REQ_LEN_NOMAC + MAX_MAC_LEN) {
- DPRINTF(5, ("bad pkt length %d\n", recv_len));
+ DPRINTF(5, ("bad pkt length %lu\n",
+ (u_long)recv_len));
msyslog(LOG_ERR,
- "process_private: bad pkt length %d",
- recv_len);
+ "process_private: bad pkt length %lu",
+ (u_long)recv_len);
req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
return;
}
lex_too_long:
yytext[min(sizeof(yytext) - 1, 50)] = 0;
msyslog(LOG_ERR,
- "configuration item on line %d longer than limit of %d, began with '%s'",
- ip_file->line_no, sizeof(yytext) - 1, yytext);
+ "configuration item on line %d longer than limit of %lu, began with '%s'",
+ ip_file->line_no, (u_long)(sizeof(yytext) - 1), yytext);
/*
* If we hit the length limit reading the startup configuration
up = (struct actsunit *)pp->unitptr;
#ifdef DEBUG
ioctl(pp->io.fd, TIOCMGET, (char *)&modem);
- snprintf(tbuf, sizeof(tbuf), "acts: %04x (%d %d) %d %s", modem,
- up->state, up->timer, strlen(pp->a_lastcode),
- pp->a_lastcode);
+ snprintf(tbuf, sizeof(tbuf), "acts: %04x (%d %d) %lu %s", modem,
+ up->state, up->timer, (u_long)strlen(pp->a_lastcode),
+ pp->a_lastcode);
if (debug)
printf("%s\n", tbuf);
#endif
* Local variables
*/
int syncdig; /* sync digit (Spectracom) */
- char sbs[6]; /* binary seconds since 0h */
- char spare[2]; /* mulligan digits */
+ char sbs[6 + 1]; /* binary seconds since 0h */
+ char spare[2 + 1]; /* mulligan digits */
int temp;
- pp = peer->procptr;
+ pp = peer->procptr;
up = (struct irigunit *)pp->unitptr;
/*
if ((size_t)datasize > (n-RESP_HEADER_SIZE)) {
if (debug)
printf(
- "Received items %d, size %d (total %d), data in packet is %d\n",
- items, size, datasize, n-RESP_HEADER_SIZE);
+ "Received items %d, size %d (total %d), data in packet is %lu\n",
+ items, size, datasize, (u_long)(n-RESP_HEADER_SIZE));
goto again;
}
return 1;
} else if (maclen != (info_auth_hashlen + sizeof(keyid_t))) {
fprintf(stderr,
- "%d octet MAC, %u expected with %u octet digest\n",
- maclen, (info_auth_hashlen + sizeof(keyid_t)),
- info_auth_hashlen);
+ "%d octet MAC, %lu expected with %lu octet digest\n",
+ maclen, (u_long)(info_auth_hashlen + sizeof(keyid_t)),
+ (u_long)info_auth_hashlen);
return 1;
}
return sendpkt(&qpkt, reqsize + maclen);
int key_type;
if (!pcmd->nargs) {
- fprintf(fp, "keytype is %s with %u octet digests\n",
+ fprintf(fp, "keytype is %s with %lu octet digests\n",
keytype_name(info_auth_keytype),
- info_auth_hashlen);
+ (u_long)info_auth_hashlen);
return;
}
)
{
if (debug >= 3)
- printf("Sending %u octets\n", xdatalen);
+ printf("Sending %lu octets\n", (u_long)xdatalen);
if (send(sockfd, xdata, (size_t)xdatalen, 0) == -1) {
warning("write to %s failed", currenthost, "");
return 1;
} else if ((size_t)maclen != (info_auth_hashlen + sizeof(keyid_t))) {
fprintf(stderr,
- "%d octet MAC, %u expected with %u octet digest\n",
- maclen, (info_auth_hashlen + sizeof(keyid_t)),
- info_auth_hashlen);
+ "%d octet MAC, %lu expected with %lu octet digest\n",
+ maclen, (u_long)(info_auth_hashlen + sizeof(keyid_t)),
+ (u_long)info_auth_hashlen);
return 1;
}
int key_type;
if (!pcmd->nargs) {
- fprintf(fp, "keytype is %s with %u octet digests\n",
+ fprintf(fp, "keytype is %s with %lu octet digests\n",
keytype_name(info_auth_keytype),
- info_auth_hashlen);
+ (u_long)info_auth_hashlen);
return;
}