Merge pull request #3 from lemoer/patch-fix-gcc
Fix type conversion warnings for gcc in SLPD
This commit is contained in:
commit
e567374a5d
2 changed files with 13 additions and 10 deletions
|
@ -1544,9 +1544,7 @@ static void handle_incoming_slpd_packet(listen_socket_t *ls, void *pkt, struct s
|
|||
node_read_ecdsa_public_key(n);
|
||||
|
||||
char sig[64];
|
||||
char b64sig[255];
|
||||
memset(&sig, 0x0, 64);
|
||||
memset(&b64sig, 0x0, 255);
|
||||
|
||||
if (miv >= 2) {
|
||||
if (b64decode(fng, &sig, 86) != 64) {
|
||||
|
@ -1570,11 +1568,11 @@ static void handle_incoming_slpd_packet(listen_socket_t *ls, void *pkt, struct s
|
|||
char iface_name[255] = { 0 };
|
||||
char fullhost[255] = { 0 };
|
||||
|
||||
if_indextoname(addr->sin6_scope_id, &iface_name);
|
||||
if_indextoname(addr->sin6_scope_id, iface_name);
|
||||
|
||||
cfg = new_config();
|
||||
cfg->variable = xstrdup("Address");
|
||||
snprintf(&fullhost, 254, "%s%%%s", addrstr, iface_name);
|
||||
snprintf(fullhost, 254, "%s%%%s", addrstr, iface_name);
|
||||
cfg->value = xstrdup(fullhost);
|
||||
cfg->file = NULL;
|
||||
cfg->line = -1;
|
||||
|
|
|
@ -375,7 +375,7 @@ void send_slpd_broadcast(char *iface) {
|
|||
|
||||
if ((sd = socket(mcast_addr->ai_family, mcast_addr->ai_socktype, 0)) < 0 ) {
|
||||
logger(DEBUG_ALWAYS, LOG_INFO, "socket() error: [%s:%d]", strerror(errno), errno);
|
||||
freeaddrinfo(&mcast_addr);
|
||||
freeaddrinfo(mcast_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -391,14 +391,14 @@ void send_slpd_broadcast(char *iface) {
|
|||
ifindex = if_nametoindex(iface);
|
||||
if(setsockopt (sd, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifindex, sizeof(ifindex)) != 0) {
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, "setsockopt() IPV6_MULTICAST_IF failed [%s:%d]", strerror(errno), errno);
|
||||
freeaddrinfo(&mcast_addr);
|
||||
freeaddrinfo(mcast_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int reuse = 1;
|
||||
if(setsockopt (sd, IPPROTO_IPV6, SO_REUSEADDR, (char*)&reuse, sizeof(reuse)) != 0) {
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, "setsockopt() SO_REUSEADDR failed: [%s:%d]", strerror(errno), errno);
|
||||
freeaddrinfo(&mcast_addr);
|
||||
freeaddrinfo(mcast_addr);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -418,13 +418,18 @@ void send_slpd_broadcast(char *iface) {
|
|||
return;
|
||||
}
|
||||
slpd_msg[MAXSIZE-1] = '\00';
|
||||
ecdsa_sign(myself->connection->ecdsa, slpd_msg, strlen(slpd_msg), &signature);
|
||||
if (b64encode(signature, &b64sig, 64) != 86) {
|
||||
|
||||
if (!ecdsa_sign(myself->connection->ecdsa, slpd_msg, strlen(slpd_msg), &signature)) {
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, "Can not sign payload for SLPD");
|
||||
return;
|
||||
}
|
||||
|
||||
if (b64encode(signature, b64sig, 64) != 86) {
|
||||
logger(DEBUG_ALWAYS, LOG_ERR, "b64encode() failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
int l = snprintf(&pkt, strlen(slpd_msg) + strlen(b64sig) + 2, "%s %s", slpd_msg, b64sig);
|
||||
int l = snprintf(pkt, strlen(slpd_msg) + strlen(b64sig) + 2, "%s %s", slpd_msg, b64sig);
|
||||
pkt[l] = '\00';
|
||||
|
||||
if (sendto(sd, pkt, strlen(pkt), 0, mcast_addr->ai_addr, mcast_addr->ai_addrlen) != strlen(pkt) ) {
|
||||
|
|
Loading…
Reference in a new issue