Skip to content

Commit

Permalink
Better document buffer lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitriPapadopoulos committed Apr 16, 2020
1 parent 547228d commit c81fde1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ static void *ssl_read(void *arg)

if (tunnel->state == STATE_CONNECTING) {
if (packet_is_ip_plus_dns(packet)) {
char line[57]; // 1 + 15 + 7 + 15 + 2 + 15 + 1 + 1
char line[ARRAY_SIZE("[xxx.xxx.xxx.xxx], ns [xxx.xxx.xxx.xxx, xxx.xxx.xxx.xxx]")];

set_tunnel_ips(tunnel, packet);
strcpy(line, "[");
Expand Down
12 changes: 8 additions & 4 deletions src/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,10 @@ int ipv4_add_nameservers_to_resolv_conf(struct tunnel *tunnel)
int ret = -1;
FILE *file;
struct stat stat;
char ns1[28], ns2[28]; // 11 + 15 + 1 + 1
char dns_suffix[MAX_DOMAIN_LENGTH+8]; // 7 + MAX_DOMAIN_LENGTH + 1
static const size_t NS_SIZE = ARRAY_SIZE("nameserver xxx.xxx.xxx.xxx");
char ns1[NS_SIZE], ns2[NS_SIZE];
static const size_t DNS_SUFFIX_SIZE = ARRAY_SIZE("search ") + MAX_DOMAIN_LENGTH;
char dns_suffix[DNS_SUFFIX_SIZE];
char *buffer = NULL;
int use_resolvconf = 0;

Expand Down Expand Up @@ -1254,8 +1256,10 @@ int ipv4_del_nameservers_from_resolv_conf(struct tunnel *tunnel)
int ret = -1;
FILE *file;
struct stat stat;
char ns1[27], ns2[27]; // 11 + 15 + 1
char dns_suffix[MAX_DOMAIN_LENGTH+8]; // 7 + MAX_DOMAIN_LENGTH + 1
static const size_t NS_SIZE = ARRAY_SIZE("nameserver xxx.xxx.xxx.xxx");
char ns1[NS_SIZE], ns2[NS_SIZE];
static const size_t DNS_SUFFIX_SIZE = ARRAY_SIZE("search ") + MAX_DOMAIN_LENGTH;
char dns_suffix[DNS_SUFFIX_SIZE];
char *buffer = NULL;
char *saveptr = NULL;

Expand Down
2 changes: 1 addition & 1 deletion tests/lint/line_length.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def endswithstring(line):
True if line ends with string, False otherwise.
"""
for end in ('"', '",', '");', '";', '" \\'):
for end in ('"', '",', '");', '";', '" \\', ')];'):
if line.endswith(end):
return True
return False
Expand Down

0 comments on commit c81fde1

Please sign in to comment.