Mark tftp_log() as __printflike() (which would have caught the bug
fixed in r246106) and deal with the fallout. MFC after: 2 weeks
This commit is contained in:
parent
33f9e1bd94
commit
b713097ae3
@ -106,13 +106,13 @@ send_packet(int peer, uint16_t block, char *pkt, int size)
|
|||||||
for (i = 0; i < 12 ; i++) {
|
for (i = 0; i < 12 ; i++) {
|
||||||
DROPPACKETn("send_packet", 0);
|
DROPPACKETn("send_packet", 0);
|
||||||
|
|
||||||
if (sendto(peer, pkt, size, 0,
|
if (sendto(peer, pkt, size, 0, (struct sockaddr *)&peer_sock,
|
||||||
(struct sockaddr *)&peer_sock, peer_sock.ss_len)
|
peer_sock.ss_len) == size) {
|
||||||
== size) {
|
|
||||||
if (i)
|
if (i)
|
||||||
tftp_log(LOG_ERR,
|
tftp_log(LOG_ERR,
|
||||||
"%s block %d, attempt %d successful",
|
"%s block %d, attempt %d successful",
|
||||||
block, i);
|
packettype(ntohs(((struct tftphdr *)
|
||||||
|
(pkt))->th_opcode)), block, i);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
tftp_log(LOG_ERR,
|
tftp_log(LOG_ERR,
|
||||||
|
@ -99,16 +99,17 @@ option_tsize(int peer __unused, struct tftphdr *tp __unused, int mode,
|
|||||||
int
|
int
|
||||||
option_timeout(int peer)
|
option_timeout(int peer)
|
||||||
{
|
{
|
||||||
|
int to;
|
||||||
|
|
||||||
if (options[OPT_TIMEOUT].o_request == NULL)
|
if (options[OPT_TIMEOUT].o_request == NULL)
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
int to = atoi(options[OPT_TIMEOUT].o_request);
|
to = atoi(options[OPT_TIMEOUT].o_request);
|
||||||
if (to < TIMEOUT_MIN || to > TIMEOUT_MAX) {
|
if (to < TIMEOUT_MIN || to > TIMEOUT_MAX) {
|
||||||
tftp_log(acting_as_client ? LOG_ERR : LOG_WARNING,
|
tftp_log(acting_as_client ? LOG_ERR : LOG_WARNING,
|
||||||
"Received bad value for timeout. "
|
"Received bad value for timeout. "
|
||||||
"Should be between %d and %d, received %s",
|
"Should be between %d and %d, received %d",
|
||||||
TIMEOUT_MIN, TIMEOUT_MAX);
|
TIMEOUT_MIN, TIMEOUT_MAX, to);
|
||||||
send_error(peer, EBADOP);
|
send_error(peer, EBADOP);
|
||||||
if (acting_as_client)
|
if (acting_as_client)
|
||||||
return (1);
|
return (1);
|
||||||
@ -195,14 +196,14 @@ option_blksize(int peer)
|
|||||||
tftp_log(LOG_ERR,
|
tftp_log(LOG_ERR,
|
||||||
"Invalid blocksize (%d bytes), "
|
"Invalid blocksize (%d bytes), "
|
||||||
"net.inet.udp.maxdgram sysctl limits it to "
|
"net.inet.udp.maxdgram sysctl limits it to "
|
||||||
"%d bytes.\n", size, maxdgram);
|
"%ld bytes.\n", size, maxdgram);
|
||||||
send_error(peer, EBADOP);
|
send_error(peer, EBADOP);
|
||||||
return (1);
|
return (1);
|
||||||
} else {
|
} else {
|
||||||
tftp_log(LOG_WARNING,
|
tftp_log(LOG_WARNING,
|
||||||
"Invalid blocksize (%d bytes), "
|
"Invalid blocksize (%d bytes), "
|
||||||
"net.inet.udp.maxdgram sysctl limits it to "
|
"net.inet.udp.maxdgram sysctl limits it to "
|
||||||
"%d bytes.\n", size, maxdgram);
|
"%ld bytes.\n", size, maxdgram);
|
||||||
size = maxdgram;
|
size = maxdgram;
|
||||||
/* No reason to return */
|
/* No reason to return */
|
||||||
}
|
}
|
||||||
@ -257,7 +258,7 @@ option_blksize2(int peer __unused)
|
|||||||
}
|
}
|
||||||
tftp_log(LOG_INFO,
|
tftp_log(LOG_INFO,
|
||||||
"Invalid blocksize2 (%d bytes), net.inet.udp.maxdgram "
|
"Invalid blocksize2 (%d bytes), net.inet.udp.maxdgram "
|
||||||
"sysctl limits it to %d bytes.\n", size, maxdgram);
|
"sysctl limits it to %ld bytes.\n", size, maxdgram);
|
||||||
size = sizes[i];
|
size = sizes[i];
|
||||||
/* No need to return */
|
/* No need to return */
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ const char *debug_show(int d);
|
|||||||
extern int tftp_logtostdout;
|
extern int tftp_logtostdout;
|
||||||
void tftp_openlog(const char *ident, int logopt, int facility);
|
void tftp_openlog(const char *ident, int logopt, int facility);
|
||||||
void tftp_closelog(void);
|
void tftp_closelog(void);
|
||||||
void tftp_log(int priority, const char *message, ...);
|
void tftp_log(int priority, const char *message, ...) __printflike(2, 3);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Performance figures
|
* Performance figures
|
||||||
|
@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -799,8 +800,8 @@ tftp_xmitfile(int peer, const char *mode)
|
|||||||
tftp_send(peer, &block, &ts);
|
tftp_send(peer, &block, &ts);
|
||||||
read_close();
|
read_close();
|
||||||
if (debug&DEBUG_SIMPLE)
|
if (debug&DEBUG_SIMPLE)
|
||||||
tftp_log(LOG_INFO, "Sent %d bytes in %d seconds",
|
tftp_log(LOG_INFO, "Sent %jd bytes in %jd seconds",
|
||||||
ts.amount, time(NULL) - now);
|
(intmax_t)ts.amount, (intmax_t)time(NULL) - now);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -832,8 +833,8 @@ tftp_recvfile(int peer, const char *mode)
|
|||||||
f = now2.tv_sec - now1.tv_sec +
|
f = now2.tv_sec - now1.tv_sec +
|
||||||
(now2.tv_usec - now1.tv_usec) / 100000.0;
|
(now2.tv_usec - now1.tv_usec) / 100000.0;
|
||||||
tftp_log(LOG_INFO,
|
tftp_log(LOG_INFO,
|
||||||
"Download of %d bytes in %d blocks completed after %0.1f seconds\n",
|
"Download of %jd bytes in %d blocks completed after %0.1f seconds\n",
|
||||||
ts.amount, block, f);
|
(intmax_t)ts.amount, block, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user