tests: tidy up types in server code
Cherry-picked from #13489 Closes #13610
This commit is contained in:
parent
7333faf00b
commit
0c49ea4ff2
@ -343,10 +343,10 @@ static int disconnect(FILE *dump, curl_socket_t fd)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* return number of bytes used */
|
/* return number of bytes used */
|
||||||
static int encode_length(size_t packetlen,
|
static size_t encode_length(size_t packetlen,
|
||||||
unsigned char *remlength) /* 4 bytes */
|
unsigned char *remlength) /* 4 bytes */
|
||||||
{
|
{
|
||||||
int bytes = 0;
|
size_t bytes = 0;
|
||||||
unsigned char encode;
|
unsigned char encode;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -396,12 +396,12 @@ static int publish(FILE *dump,
|
|||||||
size_t topiclen = strlen(topic);
|
size_t topiclen = strlen(topic);
|
||||||
unsigned char *packet;
|
unsigned char *packet;
|
||||||
size_t payloadindex;
|
size_t payloadindex;
|
||||||
ssize_t remaininglength = topiclen + 2 + payloadlen;
|
size_t remaininglength = topiclen + 2 + payloadlen;
|
||||||
ssize_t packetlen;
|
size_t packetlen;
|
||||||
ssize_t sendamount;
|
size_t sendamount;
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
unsigned char rembuffer[4];
|
unsigned char rembuffer[4];
|
||||||
int encodedlen;
|
size_t encodedlen;
|
||||||
|
|
||||||
if(config.excessive_remaining) {
|
if(config.excessive_remaining) {
|
||||||
/* manually set illegal remaining length */
|
/* manually set illegal remaining length */
|
||||||
@ -443,7 +443,7 @@ static int publish(FILE *dump,
|
|||||||
loghex(packet, rc);
|
loghex(packet, rc);
|
||||||
logprotocol(FROM_SERVER, "PUBLISH", remaininglength, dump, packet, rc);
|
logprotocol(FROM_SERVER, "PUBLISH", remaininglength, dump, packet, rc);
|
||||||
}
|
}
|
||||||
if(rc == packetlen)
|
if((size_t)rc == packetlen)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ static int fixedheader(curl_socket_t fd,
|
|||||||
|
|
||||||
/* get the first two bytes */
|
/* get the first two bytes */
|
||||||
ssize_t rc = sread(fd, (char *)buffer, 2);
|
ssize_t rc = sread(fd, (char *)buffer, 2);
|
||||||
int i;
|
size_t i;
|
||||||
if(rc < 2) {
|
if(rc < 2) {
|
||||||
logmsg("READ %zd bytes [SHORT!]", rc);
|
logmsg("READ %zd bytes [SHORT!]", rc);
|
||||||
return 1; /* fail */
|
return 1; /* fail */
|
||||||
|
|||||||
@ -89,10 +89,10 @@ typedef enum {
|
|||||||
RPROT_HTTP = 2
|
RPROT_HTTP = 2
|
||||||
} reqprot_t;
|
} reqprot_t;
|
||||||
|
|
||||||
#define SET_RTP_PKT_CHN(p,c) ((p)[1] = (unsigned char)((c) & 0xFF))
|
#define SET_RTP_PKT_CHN(p,c) ((p)[1] = (char)((c) & 0xFF))
|
||||||
|
|
||||||
#define SET_RTP_PKT_LEN(p,l) (((p)[2] = (unsigned char)(((l) >> 8) & 0xFF)), \
|
#define SET_RTP_PKT_LEN(p,l) (((p)[2] = (char)(((l) >> 8) & 0xFF)), \
|
||||||
((p)[3] = (unsigned char)((l) & 0xFF)))
|
((p)[3] = (char)((l) & 0xFF)))
|
||||||
|
|
||||||
struct httprequest {
|
struct httprequest {
|
||||||
char reqbuf[REQBUFSIZ]; /* buffer area for the incoming request */
|
char reqbuf[REQBUFSIZ]; /* buffer area for the incoming request */
|
||||||
|
|||||||
@ -179,7 +179,7 @@ static ssize_t read_wincon(int fd, void *buf, size_t count)
|
|||||||
return rcount;
|
return rcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = GetLastError();
|
errno = (int)GetLastError();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#undef read
|
#undef read
|
||||||
@ -214,7 +214,7 @@ static ssize_t write_wincon(int fd, const void *buf, size_t count)
|
|||||||
return wcount;
|
return wcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = GetLastError();
|
errno = (int)GetLastError();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#undef write
|
#undef write
|
||||||
@ -483,7 +483,7 @@ static unsigned int WINAPI select_ws_wait_thread(void *lpParameter)
|
|||||||
size.LowPart = GetFileSize(handle, &length);
|
size.LowPart = GetFileSize(handle, &length);
|
||||||
if((size.LowPart != INVALID_FILE_SIZE) ||
|
if((size.LowPart != INVALID_FILE_SIZE) ||
|
||||||
(GetLastError() == NO_ERROR)) {
|
(GetLastError() == NO_ERROR)) {
|
||||||
size.HighPart = length;
|
size.HighPart = (LONG)length;
|
||||||
/* get the current position within the file */
|
/* get the current position within the file */
|
||||||
pos.QuadPart = 0;
|
pos.QuadPart = 0;
|
||||||
pos.LowPart = SetFilePointer(handle, 0, &pos.HighPart, FILE_CURRENT);
|
pos.LowPart = SetFilePointer(handle, 0, &pos.HighPart, FILE_CURRENT);
|
||||||
|
|||||||
@ -620,7 +620,7 @@ static curl_socket_t sockit(curl_socket_t fd)
|
|||||||
memcpy(&response[SOCKS5_BNDADDR + len],
|
memcpy(&response[SOCKS5_BNDADDR + len],
|
||||||
&buffer[SOCKS5_DSTADDR + len], sizeof(socksport));
|
&buffer[SOCKS5_DSTADDR + len], sizeof(socksport));
|
||||||
|
|
||||||
rc = (send)(fd, (char *)response, (size_t)(len + 6), 0);
|
rc = (send)(fd, (char *)response, (SEND_TYPE_ARG3)(len + 6), 0);
|
||||||
if(rc != (len + 6)) {
|
if(rc != (len + 6)) {
|
||||||
logmsg("Sending connect response failed!");
|
logmsg("Sending connect response failed!");
|
||||||
return CURL_SOCKET_BAD;
|
return CURL_SOCKET_BAD;
|
||||||
|
|||||||
@ -42,9 +42,9 @@
|
|||||||
things build. */
|
things build. */
|
||||||
|
|
||||||
struct tftphdr {
|
struct tftphdr {
|
||||||
short th_opcode; /* packet type */
|
unsigned short th_opcode; /* packet type */
|
||||||
unsigned short th_block; /* all sorts of things */
|
unsigned short th_block; /* all sorts of things */
|
||||||
char th_data[1]; /* data or error string */
|
char th_data[1]; /* data or error string */
|
||||||
} PACKED_STRUCT;
|
} PACKED_STRUCT;
|
||||||
|
|
||||||
#define th_stuff th_block
|
#define th_stuff th_block
|
||||||
|
|||||||
@ -241,7 +241,8 @@ static int synchnet(curl_socket_t);
|
|||||||
|
|
||||||
static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size);
|
static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size);
|
||||||
|
|
||||||
static int validate_access(struct testcase *test, const char *fname, int mode);
|
static int validate_access(struct testcase *test,
|
||||||
|
const char *filename, unsigned short mode);
|
||||||
|
|
||||||
static void sendtftp(struct testcase *test, const struct formats *pf);
|
static void sendtftp(struct testcase *test, const struct formats *pf);
|
||||||
|
|
||||||
@ -1073,7 +1074,7 @@ static int parse_servercmd(struct testcase *req)
|
|||||||
* Validate file access.
|
* Validate file access.
|
||||||
*/
|
*/
|
||||||
static int validate_access(struct testcase *test,
|
static int validate_access(struct testcase *test,
|
||||||
const char *filename, int mode)
|
const char *filename, unsigned short mode)
|
||||||
{
|
{
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
@ -1183,7 +1184,7 @@ static void sendtftp(struct testcase *test, const struct formats *pf)
|
|||||||
nak(errno + 100);
|
nak(errno + 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sdp->th_opcode = htons((unsigned short)opcode_DATA);
|
sdp->th_opcode = htons(opcode_DATA);
|
||||||
sdp->th_block = htons(sendblock);
|
sdp->th_block = htons(sendblock);
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
#ifdef HAVE_SIGSETJMP
|
#ifdef HAVE_SIGSETJMP
|
||||||
@ -1218,7 +1219,7 @@ send_data:
|
|||||||
logmsg("read: fail");
|
logmsg("read: fail");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sap->th_opcode = ntohs((unsigned short)sap->th_opcode);
|
sap->th_opcode = ntohs(sap->th_opcode);
|
||||||
sap->th_block = ntohs(sap->th_block);
|
sap->th_block = ntohs(sap->th_block);
|
||||||
|
|
||||||
if(sap->th_opcode == opcode_ERROR) {
|
if(sap->th_opcode == opcode_ERROR) {
|
||||||
@ -1261,7 +1262,7 @@ static void recvtftp(struct testcase *test, const struct formats *pf)
|
|||||||
rap = &ackbuf.hdr;
|
rap = &ackbuf.hdr;
|
||||||
do {
|
do {
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
rap->th_opcode = htons((unsigned short)opcode_ACK);
|
rap->th_opcode = htons(opcode_ACK);
|
||||||
rap->th_block = htons(recvblock);
|
rap->th_block = htons(recvblock);
|
||||||
recvblock++;
|
recvblock++;
|
||||||
#ifdef HAVE_SIGSETJMP
|
#ifdef HAVE_SIGSETJMP
|
||||||
@ -1290,7 +1291,7 @@ send_ack:
|
|||||||
logmsg("read: fail");
|
logmsg("read: fail");
|
||||||
goto abort;
|
goto abort;
|
||||||
}
|
}
|
||||||
rdp->th_opcode = ntohs((unsigned short)rdp->th_opcode);
|
rdp->th_opcode = ntohs(rdp->th_opcode);
|
||||||
rdp->th_block = ntohs(rdp->th_block);
|
rdp->th_block = ntohs(rdp->th_block);
|
||||||
if(rdp->th_opcode == opcode_ERROR)
|
if(rdp->th_opcode == opcode_ERROR)
|
||||||
goto abort;
|
goto abort;
|
||||||
@ -1321,8 +1322,7 @@ send_ack:
|
|||||||
test->ofile = 0;
|
test->ofile = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rap->th_opcode = htons((unsigned short)opcode_ACK); /* send the "final"
|
rap->th_opcode = htons(opcode_ACK); /* send the "final" ack */
|
||||||
ack */
|
|
||||||
rap->th_block = htons(recvblock);
|
rap->th_block = htons(recvblock);
|
||||||
(void) swrite(peer, &ackbuf.storage[0], 4);
|
(void) swrite(peer, &ackbuf.storage[0], 4);
|
||||||
#if defined(HAVE_ALARM) && defined(SIGALRM)
|
#if defined(HAVE_ALARM) && defined(SIGALRM)
|
||||||
@ -1361,7 +1361,7 @@ static void nak(int error)
|
|||||||
struct errmsg *pe;
|
struct errmsg *pe;
|
||||||
|
|
||||||
tp = &buf.hdr;
|
tp = &buf.hdr;
|
||||||
tp->th_opcode = htons((unsigned short)opcode_ERROR);
|
tp->th_opcode = htons(opcode_ERROR);
|
||||||
tp->th_code = htons((unsigned short)error);
|
tp->th_code = htons((unsigned short)error);
|
||||||
for(pe = errmsgs; pe->e_code >= 0; pe++)
|
for(pe = errmsgs; pe->e_code >= 0; pe++)
|
||||||
if(pe->e_code == error)
|
if(pe->e_code == error)
|
||||||
|
|||||||
@ -147,7 +147,7 @@ static const char *win32_strerror(int err, char *buf, size_t buflen)
|
|||||||
void win32_perror(const char *msg)
|
void win32_perror(const char *msg)
|
||||||
{
|
{
|
||||||
char buf[512];
|
char buf[512];
|
||||||
DWORD err = SOCKERRNO;
|
int err = SOCKERRNO;
|
||||||
win32_strerror(err, buf, sizeof(buf));
|
win32_strerror(err, buf, sizeof(buf));
|
||||||
if(msg)
|
if(msg)
|
||||||
fprintf(stderr, "%s: ", msg);
|
fprintf(stderr, "%s: ", msg);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user