Page MenuHomeFreeBSD

D44954.diff
No OneTemporary

D44954.diff

diff --git a/libexec/tftpd/tests/functional.c b/libexec/tftpd/tests/functional.c
--- a/libexec/tftpd/tests/functional.c
+++ b/libexec/tftpd/tests/functional.c
@@ -51,8 +51,8 @@
static bool w_flag = false; /* Pass -w to tftpd */
/* Helper functions*/
-static void require_bufeq(const char *expected, ssize_t expected_len,
- const char *actual, ssize_t len);
+static void require_bufeq(const char *expected, size_t expected_len,
+ const char *actual, size_t len);
/*
* Receive a response from tftpd
@@ -68,7 +68,7 @@
(struct sockaddr*)&from, &fromlen); \
ATF_REQUIRE(r > 0); \
require_bufeq((hdr), sizeof(hdr), buffer, \
- MIN(r, (ssize_t)sizeof(hdr))); \
+ MIN((size_t)r, sizeof(hdr))); \
require_bufeq((const char*) (contents), (contents_len), \
&buffer[sizeof(hdr)], r - sizeof(hdr)); \
if (protocol == PF_INET) { \
@@ -117,12 +117,13 @@
* @param cmd Command to send, as a char array
*/
static void
-send_bytes(const void* cmd, ssize_t len)
+send_bytes(const void *cmd, size_t len)
{
ssize_t r;
r = sendto(s, cmd, len, 0, (struct sockaddr*)(&addr), addr.ss_len);
- ATF_REQUIRE_EQ(r, len);
+ ATF_REQUIRE(r >= 0);
+ ATF_REQUIRE_EQ(len, (size_t)r);
}
static void
@@ -261,16 +262,16 @@
/* Assert that two binary buffers are identical */
static void
-require_bufeq(const char *expected, ssize_t expected_len, const char *actual,
- ssize_t len)
+require_bufeq(const char *expected, size_t expected_len, const char *actual,
+ size_t len)
{
- ssize_t i;
+ size_t i;
ATF_REQUIRE_EQ_MSG(expected_len, len,
- "Expected %zd bytes but got %zd", expected_len, len);
+ "Expected %zu bytes but got %zu", expected_len, len);
for (i = 0; i < len; i++) {
ATF_REQUIRE_EQ_MSG(actual[i], expected[i],
- "Expected %#hhx at position %zd; got %hhx instead",
+ "Expected %#hhx at position %zu; got %hhx instead",
expected[i], i, actual[i]);
}
}
@@ -391,8 +392,8 @@
while (nbytes > 0) {
r = write(fd, buf, nbytes);
ATF_REQUIRE(r > 0);
- nbytes -= r;
- buf = (const char*)buf + r;
+ nbytes -= (size_t)r;
+ buf = (const char*)buf + (size_t)r;
}
}
@@ -804,8 +805,9 @@
fd = open("small.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq(contents, contents_len, buffer, r);
+ require_bufeq(contents, contents_len, buffer, (size_t)r);
}
/*
@@ -841,8 +843,9 @@
fd = open("medium.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq((const char*)contents, 768, buffer, r);
+ require_bufeq((const char*)contents, 768, buffer, (size_t)r);
}
/*
@@ -874,8 +877,9 @@
fd = open("small.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq(contents, contents_len, buffer, r);
+ require_bufeq(contents, contents_len, buffer, (size_t)r);
}
/*
@@ -908,8 +912,9 @@
fd = open("medium.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq((const char*)contents, 768, buffer, r);
+ require_bufeq((const char*)contents, 768, buffer, (size_t)r);
}
/*
@@ -972,8 +977,9 @@
fd = open("medium.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq((const char*)contents, 768, buffer, r);
+ require_bufeq((const char*)contents, 768, buffer, (size_t)r);
}
/*
@@ -1004,8 +1010,9 @@
fd = open("medium.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq((const char*)contents, 768, buffer, r);
+ require_bufeq((const char*)contents, 768, buffer, (size_t)r);
}
/*
@@ -1037,8 +1044,9 @@
fd = open("unix.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq(expected, sizeof(expected), buffer, r);
+ require_bufeq(expected, sizeof(expected), buffer, (size_t)r);
}
/*
@@ -1075,8 +1083,9 @@
fd = open("small.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq(contents, contents_len, buffer, r);
+ require_bufeq(contents, contents_len, buffer, (size_t)r);
}
/*
@@ -1162,8 +1171,9 @@
fd = open("rfc7440.txt", O_RDONLY);
ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
+ ATF_REQUIRE(r > 0);
close(fd);
- require_bufeq(contents, sizeof(contents), buffer, r);
+ require_bufeq(contents, sizeof(contents), buffer, (size_t)r);
}
diff --git a/libexec/tftpd/tftp-utils.h b/libexec/tftpd/tftp-utils.h
--- a/libexec/tftpd/tftp-utils.h
+++ b/libexec/tftpd/tftp-utils.h
@@ -63,7 +63,7 @@
/*
*/
void unmappedaddr(struct sockaddr_in6 *sin6);
-ssize_t get_field(int peer, char *buffer, ssize_t size);
+size_t get_field(int peer, char *buffer, size_t size);
/*
* Packet types
diff --git a/libexec/tftpd/tftp-utils.c b/libexec/tftpd/tftp-utils.c
--- a/libexec/tftpd/tftp-utils.c
+++ b/libexec/tftpd/tftp-utils.c
@@ -104,8 +104,8 @@
}
/* Get a field from a \0 separated string */
-ssize_t
-get_field(int peer, char *buffer, ssize_t size)
+size_t
+get_field(int peer, char *buffer, size_t size)
{
char *cp = buffer;
diff --git a/libexec/tftpd/tftpd.c b/libexec/tftpd/tftpd.c
--- a/libexec/tftpd/tftpd.c
+++ b/libexec/tftpd/tftpd.c
@@ -68,8 +68,8 @@
#include <tcpd.h>
#endif
-static void tftp_wrq(int peer, char *, ssize_t);
-static void tftp_rrq(int peer, char *, ssize_t);
+static void tftp_wrq(int peer, char *, size_t);
+static void tftp_rrq(int peer, char *, size_t);
/*
* Null-terminated directory prefix list for absolute pathname requests and
@@ -81,7 +81,7 @@
#define MAXDIRS 20
static struct dirlist {
const char *name;
- int len;
+ size_t len;
} dirs[MAXDIRS+1];
static int suppress_naks;
static int logging;
@@ -392,7 +392,7 @@
tp->th_opcode = ntohs(tp->th_opcode);
if (tp->th_opcode == RRQ) {
if (allow_ro)
- tftp_rrq(peer, tp->th_stuff, n - 1);
+ tftp_rrq(peer, tp->th_stuff, (size_t)n - 1);
else {
tftp_log(LOG_WARNING,
"%s read access denied", peername);
@@ -400,7 +400,7 @@
}
} else if (tp->th_opcode == WRQ) {
if (allow_wo)
- tftp_wrq(peer, tp->th_stuff, n - 1);
+ tftp_wrq(peer, tp->th_stuff, (size_t)n - 1);
else {
tftp_log(LOG_WARNING,
"%s write access denied", peername);
@@ -443,7 +443,7 @@
}
static char *
-parse_header(int peer, char *recvbuffer, ssize_t size,
+parse_header(int peer, char *recvbuffer, size_t size,
char **filename, char **mode)
{
char *cp;
@@ -489,7 +489,7 @@
* WRQ - receive a file from the client
*/
void
-tftp_wrq(int peer, char *recvbuffer, ssize_t size)
+tftp_wrq(int peer, char *recvbuffer, size_t size)
{
char *cp;
int has_options = 0, ecode;
@@ -534,7 +534,7 @@
* RRQ - send a file to the client
*/
void
-tftp_rrq(int peer, char *recvbuffer, ssize_t size)
+tftp_rrq(int peer, char *recvbuffer, size_t size)
{
char *cp;
int has_options = 0, ecode;

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 9, 9:38 AM (21 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14555813
Default Alt Text
D44954.diff (6 KB)

Event Timeline