Fix potentially unterminated strings
This commit is contained in:
parent
078359127b
commit
ae91d6b4b1
|
@ -1094,7 +1094,7 @@ resolv_set_hostname(const char *hostname)
|
||||||
/* Add the .local suffix if it isn't already there */
|
/* Add the .local suffix if it isn't already there */
|
||||||
if(strlen(resolv_hostname) < 7 ||
|
if(strlen(resolv_hostname) < 7 ||
|
||||||
strcasecmp(resolv_hostname + strlen(resolv_hostname) - 6, ".local") != 0) {
|
strcasecmp(resolv_hostname + strlen(resolv_hostname) - 6, ".local") != 0) {
|
||||||
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE);
|
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE - strlen(resolv_hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINTF("resolver: hostname changed to \"%s\"\n", resolv_hostname);
|
PRINTF("resolver: hostname changed to \"%s\"\n", resolv_hostname);
|
||||||
|
@ -1248,8 +1248,8 @@ remove_trailing_dots(const char *name) {
|
||||||
static char dns_name_without_dots[RESOLV_CONF_MAX_DOMAIN_NAME_SIZE + 1];
|
static char dns_name_without_dots[RESOLV_CONF_MAX_DOMAIN_NAME_SIZE + 1];
|
||||||
size_t len = strlen(name);
|
size_t len = strlen(name);
|
||||||
|
|
||||||
if(name[len - 1] == '.') {
|
if(len && name[len - 1] == '.') {
|
||||||
strncpy(dns_name_without_dots, name, sizeof(dns_name_without_dots));
|
strncpy(dns_name_without_dots, name, RESOLV_CONF_MAX_DOMAIN_NAME_SIZE);
|
||||||
while(len && (dns_name_without_dots[len - 1] == '.')) {
|
while(len && (dns_name_without_dots[len - 1] == '.')) {
|
||||||
dns_name_without_dots[--len] = 0;
|
dns_name_without_dots[--len] = 0;
|
||||||
}
|
}
|
||||||
|
@ -1309,7 +1309,7 @@ resolv_query(const char *name)
|
||||||
|
|
||||||
memset(nameptr, 0, sizeof(*nameptr));
|
memset(nameptr, 0, sizeof(*nameptr));
|
||||||
|
|
||||||
strncpy(nameptr->name, name, sizeof(nameptr->name));
|
strncpy(nameptr->name, name, sizeof(nameptr->name) - 1);
|
||||||
nameptr->state = STATE_NEW;
|
nameptr->state = STATE_NEW;
|
||||||
nameptr->seqno = seqno;
|
nameptr->seqno = seqno;
|
||||||
++seqno;
|
++seqno;
|
||||||
|
@ -1479,7 +1479,7 @@ resolv_found(char *name, uip_ipaddr_t * ipaddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Re-add the .local suffix */
|
/* Re-add the .local suffix */
|
||||||
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE);
|
strncat(resolv_hostname, ".local", RESOLV_CONF_MAX_DOMAIN_NAME_SIZE - strlen(resolv_hostname));
|
||||||
|
|
||||||
start_name_collision_check(CLOCK_SECOND * 5);
|
start_name_collision_check(CLOCK_SECOND * 5);
|
||||||
} else if(mdns_state == MDNS_STATE_READY) {
|
} else if(mdns_state == MDNS_STATE_READY) {
|
||||||
|
|
|
@ -547,8 +547,8 @@ websocket_open(struct websocket *s, const char *url,
|
||||||
websocket_callback c)
|
websocket_callback c)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char host[MAX_HOSTLEN];
|
char host[MAX_HOSTLEN + 1] = {0};
|
||||||
char path[MAX_PATHLEN];
|
char path[MAX_PATHLEN + 1] = {0};
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
uip_ipaddr_t addr;
|
uip_ipaddr_t addr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue