mirror of
https://github.com/yarrick/iodine.git
synced 2025-04-10 04:21:01 +00:00
Fix compiler warnings
This commit is contained in:
parent
27e5d6fadd
commit
81f8e022c1
5 changed files with 23 additions and 14 deletions
16
src/client.c
16
src/client.c
|
@ -1266,7 +1266,7 @@ send_ip_request(int fd, int userid)
|
||||||
buf[4] = b32_5to8((rand_seed ) & 0x1f);
|
buf[4] = b32_5to8((rand_seed ) & 0x1f);
|
||||||
rand_seed++;
|
rand_seed++;
|
||||||
|
|
||||||
strncat(buf, topdomain, 512 - strlen(buf));
|
strncat(buf, topdomain, 511 - strlen(buf));
|
||||||
send_query(fd, buf);
|
send_query(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1290,9 +1290,9 @@ send_upenctest(int fd, const char *s)
|
||||||
buf[3] = b32_5to8((rand_seed ) & 0x1f);
|
buf[3] = b32_5to8((rand_seed ) & 0x1f);
|
||||||
rand_seed++;
|
rand_seed++;
|
||||||
|
|
||||||
strncat(buf, s, 512);
|
strncat(buf, s, 511);
|
||||||
strncat(buf, ".", 512);
|
strncat(buf, ".", 511);
|
||||||
strncat(buf, topdomain, 512 - strlen(buf));
|
strncat(buf, topdomain, 511 - strlen(buf));
|
||||||
send_query(fd, buf);
|
send_query(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,7 +1310,7 @@ send_downenctest(int fd, char downenc, int variant, char *s, int slen)
|
||||||
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
||||||
rand_seed++;
|
rand_seed++;
|
||||||
|
|
||||||
strncat(buf, topdomain, 512 - strlen(buf));
|
strncat(buf, topdomain, 511 - strlen(buf));
|
||||||
send_query(fd, buf);
|
send_query(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1326,7 +1326,7 @@ send_codec_switch(int fd, int userid, int bits)
|
||||||
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
||||||
rand_seed++;
|
rand_seed++;
|
||||||
|
|
||||||
strncat(buf, topdomain, 512 - strlen(buf));
|
strncat(buf, topdomain, 511 - strlen(buf));
|
||||||
send_query(fd, buf);
|
send_query(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1343,7 +1343,7 @@ send_downenc_switch(int fd, int userid)
|
||||||
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
||||||
rand_seed++;
|
rand_seed++;
|
||||||
|
|
||||||
strncat(buf, topdomain, 512 - strlen(buf));
|
strncat(buf, topdomain, 511 - strlen(buf));
|
||||||
send_query(fd, buf);
|
send_query(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1363,7 +1363,7 @@ send_lazy_switch(int fd, int userid)
|
||||||
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
buf[5] = b32_5to8((rand_seed ) & 0x1f);
|
||||||
rand_seed++;
|
rand_seed++;
|
||||||
|
|
||||||
strncat(buf, topdomain, 512 - strlen(buf));
|
strncat(buf, topdomain, 511 - strlen(buf));
|
||||||
send_query(fd, buf);
|
send_query(fd, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,17 +16,20 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
|
|
||||||
int build_hostname(char *buf, size_t buflen, const char *data,
|
int build_hostname(char *buf, size_t buflen, const char *data,
|
||||||
const size_t datalen, const char *topdomain,
|
const size_t datalen, const char *topdomain,
|
||||||
const struct encoder *encoder, int maxlen)
|
const struct encoder *encoder, size_t maxlen)
|
||||||
{
|
{
|
||||||
size_t space;
|
size_t space;
|
||||||
char *b;
|
char *b;
|
||||||
|
size_t topdomainlen = strlen(topdomain);
|
||||||
|
char *bufstart = buf;
|
||||||
|
|
||||||
space = MIN((size_t)maxlen, buflen) - strlen(topdomain) - 8;
|
space = MIN(maxlen, buflen) - topdomainlen - 8;
|
||||||
/* 8 = 5 max header length + 1 dot before topdomain + 2 safety */
|
/* 8 = 5 max header length + 1 dot before topdomain + 2 safety */
|
||||||
|
|
||||||
if (!encoder->places_dots)
|
if (!encoder->places_dots)
|
||||||
|
@ -49,7 +52,8 @@ int build_hostname(char *buf, size_t buflen, const char *data,
|
||||||
b++;
|
b++;
|
||||||
/* move b ahead of the string so we can copy to it */
|
/* move b ahead of the string so we can copy to it */
|
||||||
|
|
||||||
strncpy(b, topdomain, strlen(topdomain)+1);
|
assert((*b - *bufstart) >= topdomainlen+1);
|
||||||
|
strncpy(b, topdomain, topdomainlen+1);
|
||||||
|
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ struct encoder {
|
||||||
};
|
};
|
||||||
|
|
||||||
int build_hostname(char *, size_t, const char *, const size_t, const char *,
|
int build_hostname(char *, size_t, const char *, const size_t, const char *,
|
||||||
const struct encoder *, int);
|
const struct encoder *, size_t);
|
||||||
int unpack_data(char *, size_t, char *, size_t, const struct encoder *);
|
int unpack_data(char *, size_t, char *, size_t, const struct encoder *);
|
||||||
int inline_dotify(char *, size_t);
|
int inline_dotify(char *, size_t);
|
||||||
int inline_undotify(char *, size_t);
|
int inline_undotify(char *, size_t);
|
||||||
|
|
|
@ -2391,9 +2391,9 @@ main(int argc, char **argv)
|
||||||
int retval;
|
int retval;
|
||||||
int max_idle_time = 0;
|
int max_idle_time = 0;
|
||||||
struct sockaddr_storage dns4addr;
|
struct sockaddr_storage dns4addr;
|
||||||
int dns4addr_len;
|
int dns4addr_len = 0;
|
||||||
struct sockaddr_storage dns6addr;
|
struct sockaddr_storage dns6addr;
|
||||||
int dns6addr_len;
|
int dns6addr_len = 0;
|
||||||
#ifdef HAVE_SYSTEMD
|
#ifdef HAVE_SYSTEMD
|
||||||
int nb_fds;
|
int nb_fds;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#ifdef WINDOWS32
|
#ifdef WINDOWS32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
@ -63,11 +64,15 @@ int init_users(in_addr_t my_ip, int netbits)
|
||||||
for (i = 0; i < usercount; i++) {
|
for (i = 0; i < usercount; i++) {
|
||||||
in_addr_t ip;
|
in_addr_t ip;
|
||||||
users[i].id = i;
|
users[i].id = i;
|
||||||
|
assert(0 <= (i + skip + 1));
|
||||||
|
assert(255 >= (i + skip + 1));
|
||||||
snprintf(newip, sizeof(newip), "0.0.0.%d", i + skip + 1);
|
snprintf(newip, sizeof(newip), "0.0.0.%d", i + skip + 1);
|
||||||
ip = ipstart.s_addr + inet_addr(newip);
|
ip = ipstart.s_addr + inet_addr(newip);
|
||||||
if (ip == my_ip && skip == 0) {
|
if (ip == my_ip && skip == 0) {
|
||||||
/* This IP was taken by iodined */
|
/* This IP was taken by iodined */
|
||||||
skip++;
|
skip++;
|
||||||
|
assert(0 <= (i + skip + 1));
|
||||||
|
assert(255 >= (i + skip + 1));
|
||||||
snprintf(newip, sizeof(newip), "0.0.0.%d", i + skip + 1);
|
snprintf(newip, sizeof(newip), "0.0.0.%d", i + skip + 1);
|
||||||
ip = ipstart.s_addr + inet_addr(newip);
|
ip = ipstart.s_addr + inet_addr(newip);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue