printf("Chat started.\nType /help for a list of commands.\n");
- while(fgets(buf, sizeof buf, stdin))
+ while(fgets(buf, sizeof(buf), stdin))
parse_input(mesh, buf);
printf("Chat stopping.\n");
printf("Chat started.\nType /help for a list of commands.\n");
- while(fgets(buf, sizeof buf, stdin))
+ while(fgets(buf, sizeof(buf), stdin))
parse_input(mesh, buf);
printf("Chat stopping.\n");
printf("Chat started.\nType /help for a list of commands.\n");
- while(fgets(buf, sizeof buf, stdin))
+ while(fgets(buf, sizeof(buf), stdin))
parse_input(&mesh, buf);
printf("Chat stopping.\n");
if(argc > 4)
graphexporttimeout = argv[4];
- mesh = calloc(n, sizeof *mesh);
+ mesh = calloc(n, sizeof(*mesh));
meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_message);
#ifndef _WIN32
char filename[PATH_MAX];
char nodename[100];
for(int i = 0; i < n; i++) {
- snprintf(nodename, sizeof nodename, "%snode%d", namesprefix,i);
- snprintf(filename, sizeof filename, "%s/%s", basebase, nodename);
+ snprintf(nodename, sizeof(nodename), "%snode%d", namesprefix,i);
+ snprintf(filename, sizeof(filename), "%s/%s", basebase, nodename);
bool itsnew = access(filename, R_OK);
if(n/(i+1) > n/4)
mesh[i] = meshlink_open(filename, nodename, "manynodes", DEV_CLASS_BACKBONE);
printf("%d nodes started.\nType /help for a list of commands.\n", started);
// handle input
- while(fgets(buf, sizeof buf, stdin))
+ while(fgets(buf, sizeof(buf), stdin))
parse_input(buf);
exportmeshgraph_end(NULL);
}
for(;;) {
- line = readline(fp, buffer, sizeof buffer);
+ line = readline(fp, buffer, sizeof(buffer));
if(!line) {
if(feof(fp))
char tmpname[PATH_MAX];
bool error = false;
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
- snprintf(tmpname, sizeof tmpname, "%s.tmp", filename);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
+ snprintf(tmpname, sizeof(tmpname), "%s.tmp", filename);
FILE *fr = fopen(filename, "r");
char *sep;
bool found = false;
- while(readline(fr, buf, sizeof buf)) {
+ while(readline(fr, buf, sizeof(buf))) {
if(!*buf || *buf == '#')
goto copy;
// Try to atomically replace the old config file with the new one.
#ifdef HAVE_MINGW
char bakname[PATH_MAX];
- snprintf(bakname, sizeof bakname, "%s.bak", filename);
+ snprintf(bakname, sizeof(bakname), "%s.bak", filename);
if(rename(filename, bakname) || rename(tmpname, filename)) {
rename(bakname, filename);
#else
// Start the discovery thread
if(pthread_create(&mesh->discovery_thread, NULL, discovery_loop, mesh) != 0) {
logger(mesh, MESHLINK_ERROR, "Could not start discovery thread: %s\n", strerror(errno));
- memset(&mesh->discovery_thread, 0, sizeof mesh->discovery_thread);
+ memset(&mesh->discovery_thread, 0, sizeof(mesh)->discovery_thread);
goto fail;
}
tv = ⁢
}
- memcpy(&readable, &loop->readfds, sizeof readable);
- memcpy(&writable, &loop->writefds, sizeof writable);
+ memcpy(&readable, &loop->readfds, sizeof(readable));
+ memcpy(&writable, &loop->writefds, sizeof(writable));
int fds = 0;
if(!n->status.reachable) {
update_node_udp(mesh, n, NULL);
- memset(&n->status, 0, sizeof n->status);
+ memset(&n->status, 0, sizeof(n)->status);
n->options = 0;
} else if(n->connection) {
if(n->connection->outgoing)
/* (De)allocation */
hash_t *hash_alloc(size_t n, size_t size) {
- hash_t *hash = xzalloc(sizeof *hash);
+ hash_t *hash = xzalloc(sizeof(*hash));
hash->n = n;
hash->size = size;
hash->keys = xzalloc(hash->n * hash->size);
- hash->values = xzalloc(hash->n * sizeof *hash->values);
+ hash->values = xzalloc(hash->n * sizeof(*hash->values));
return hash;
}
/* Utility functions */
void hash_clear(hash_t *hash) {
- memset(hash->values, 0, hash->n * sizeof *hash->values);
+ memset(hash->values, 0, hash->n * sizeof(*hash->values));
}
void hash_resize(hash_t *hash, size_t n) {
hash->keys = xrealloc(hash->keys, n * hash->size);
- hash->values = xrealloc(hash->values, n * sizeof *hash->values);
+ hash->values = xrealloc(hash->values, n * sizeof(*hash->values));
if(n > hash->n) {
memset(hash->keys + hash->n * hash->size, 0, (n - hash->n) * hash->size);
- memset(hash->values + hash->n, 0, (n - hash->n) * sizeof *hash->values);
+ memset(hash->values + hash->n, 0, (n - hash->n) * sizeof(*hash->values));
}
}
char message[1024] = "";
va_start(ap, format);
- int len = vsnprintf(message, sizeof message, format, ap);
+ int len = vsnprintf(message, sizeof(message), format, ap);
va_end(ap);
- if(len > 0 && len < sizeof message && message[len - 1] == '\n')
+ if(len > 0 && len < sizeof(message) && message[len - 1] == '\n')
message[len - 1] = 0;
if(mesh)
char buf[1024];
size_t len;
- while((len = fread(buf, 1, sizeof buf, in)))
+ while((len = fread(buf, 1, sizeof(buf), in)))
fwrite(buf, len, 1, out);
fclose(in);
return true;
if(!f)
return;
- while(fgets(line, sizeof line, f)) {
+ while(fgets(line, sizeof(line), f)) {
if(!rstrip(line))
continue;
char *p = line, *q;
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
#endif
- setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv);
- setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv);
+ setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
}
char *meshlink_get_external_address(meshlink_handle_t *mesh) {
}
}
if(s >= 0) {
- send(s, request, sizeof request - 1, 0);
- int len = recv(s, line, sizeof line - 1, MSG_WAITALL);
+ send(s, request, sizeof(request) - 1, 0);
+ int len = recv(s, line, sizeof(line) - 1, MSG_WAITALL);
if(len > 0) {
line[len] = 0;
if(line[len - 1] == '\n')
FILE *f;
// Use first Address statement in own host config file
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
scan_for_hostname(filename, &hostname, &port);
if(hostname)
static char line[1024];
const char *end = strchr(*data, '\n');
size_t len = end ? end - *data : strlen(*data);
- if(len >= sizeof line) {
+ if(len >= sizeof(line)) {
logger(NULL, MESHLINK_ERROR, "Maximum line length exceeded!\n");
return NULL;
}
};
char portstr[16];
- snprintf(portstr, sizeof portstr, "%d", port);
+ snprintf(portstr, sizeof(portstr), "%d", port);
if(getaddrinfo(NULL, portstr, &hint, &ai) || !ai)
return false;
int port = 0x1000 + (rand() & 0x7fff);
if(try_bind(port)) {
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->name);
FILE *f = fopen(filename, "a");
if(!f) {
logger(mesh, MESHLINK_DEBUG, "Please change MeshLink's Port manually.\n");
}
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "meshlink.conf", mesh->confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "meshlink.conf", mesh->confbase);
FILE *f = fopen(filename, "w");
if(!f) {
fprintf(f, "Name = %s\n", name);
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
FILE *fh = fopen(filename, "w");
if(!fh) {
logger(mesh, MESHLINK_DEBUG, "Could not create file %s: %s\n", filename, strerror(errno));
return false;
}
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, value);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, value);
f = fopen(filename, "w");
if(!f) {
meshlink_handle_t* mesh = handle;
switch(type) {
case SPTPS_HANDSHAKE:
- return sptps_send_record(&(mesh->sptps), 0, mesh->cookie, sizeof mesh->cookie);
+ return sptps_send_record(&(mesh->sptps), 0, mesh->cookie, sizeof(mesh)->cookie);
case 0:
mesh->data = xrealloc(mesh->data, mesh->thedatalen + len + 1);
abort();
while(!(newline = memchr(mesh->buffer, '\n', mesh->blen))) {
- int result = recv(mesh->sock, mesh->buffer + mesh->blen, sizeof mesh->buffer - mesh->blen, 0);
+ int result = recv(mesh->sock, mesh->buffer + mesh->blen, sizeof(mesh)->buffer - mesh->blen, 0);
if(result == -1 && errno == EINTR)
continue;
else if(result <= 0)
va_list ap;
va_start(ap, format);
- blen = vsnprintf(buffer, sizeof buffer, format, ap);
+ blen = vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
- if(blen < 1 || blen >= sizeof buffer)
+ if(blen < 1 || blen >= sizeof(buffer))
return false;
buffer[blen] = '\n';
};
const char *meshlink_strerror(meshlink_errno_t err) {
- if(err < 0 || err >= sizeof errstr / sizeof *errstr)
+ if(err < 0 || err >= sizeof(errstr) / sizeof(*errstr))
return "Invalid error code";
return errstr[err];
}
} else
logger(mesh, MESHLINK_DEBUG, "Done.\n");
- snprintf(privname, sizeof privname, "%s" SLASH "ecdsa_key.priv", mesh->confbase);
+ snprintf(privname, sizeof(privname), "%s" SLASH "ecdsa_key.priv", mesh->confbase);
f = fopen(privname, "wb");
if(!f) {
fclose(f);
- snprintf(pubname, sizeof pubname, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->name);
+ snprintf(pubname, sizeof(pubname), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->name);
f = fopen(pubname, "a");
if(!f) {
freeaddrinfo(rai);
struct sockaddr_storage sn;
- socklen_t sl = sizeof sn;
+ socklen_t sl = sizeof(sn);
if(getsockname(sock, (struct sockaddr *)&sn, &sl))
return false;
// IPv4 example.org
- if(getlocaladdrname("93.184.216.34", host, sizeof host)) {
- snprintf(entry, sizeof entry, "%s %s", host, mesh->myport);
+ if(getlocaladdrname("93.184.216.34", host, sizeof(host))) {
+ snprintf(entry, sizeof(entry), "%s %s", host, mesh->myport);
append_config_file(mesh, mesh->name, "Address", entry);
}
// IPv6 example.org
- if(getlocaladdrname("2606:2800:220:1:248:1893:25c8:1946", host, sizeof host)) {
- snprintf(entry, sizeof entry, "%s %s", host, mesh->myport);
+ if(getlocaladdrname("2606:2800:220:1:248:1893:25c8:1946", host, sizeof(host))) {
+ snprintf(entry, sizeof(entry), "%s %s", host, mesh->myport);
append_config_file(mesh, mesh->name, "Address", entry);
}
}
}
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "hosts", mesh->confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts", mesh->confbase);
if(mkdir(filename, 0777) && errno != EEXIST) {
logger(mesh, MESHLINK_DEBUG, "Could not create directory %s: %s\n", filename, strerror(errno));
return false;
}
- snprintf(filename, sizeof filename, "%s" SLASH "meshlink.conf", mesh->confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "meshlink.conf", mesh->confbase);
if(!access(filename, F_OK)) {
logger(mesh, MESHLINK_DEBUG, "Configuration file %s already exists!\n", filename);
// Check whether meshlink.conf already exists
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "meshlink.conf", confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "meshlink.conf", confbase);
if(access(filename, R_OK)) {
if(errno == ENOENT) {
if(pthread_create(&mesh->thread, NULL, meshlink_main_loop, mesh) != 0) {
logger(mesh, MESHLINK_DEBUG, "Could not start thread: %s\n", strerror(errno));
- memset(&mesh->thread, 0, sizeof mesh->thread);
+ memset(&mesh->thread, 0, sizeof(mesh)->thread);
meshlink_errno = MESHLINK_EINTERNAL;
pthread_mutex_unlock(&(mesh->mesh_mutex));
return false;
free(mesh->confbase);
pthread_mutex_destroy(&(mesh->mesh_mutex));
- memset(mesh, 0, sizeof *mesh);
+ memset(mesh, 0, sizeof(*mesh));
free(mesh);
}
if(ent->d_name[0] == '.')
continue;
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "%s", dirname, ent->d_name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "%s", dirname, ent->d_name);
if(unlink(filename))
deltree(filename);
}
}
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "meshlink.conf", confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "meshlink.conf", confbase);
if(unlink(filename)) {
if(errno == ENOENT) {
meshlink_packethdr_t *hdr;
// Validate arguments
- if(!mesh || !destination || len >= MAXSIZE - sizeof *hdr) {
+ if(!mesh || !destination || len >= MAXSIZE - sizeof(*hdr)) {
meshlink_errno = MESHLINK_EINVAL;
return false;
}
}
// Prepare the packet
- vpn_packet_t *packet = malloc(sizeof *packet);
+ vpn_packet_t *packet = malloc(sizeof(*packet));
if(!packet) {
meshlink_errno = MESHLINK_ENOMEM;
return false;
packet->probe = false;
packet->tcp = false;
- packet->len = len + sizeof *hdr;
+ packet->len = len + sizeof(*hdr);
hdr = (meshlink_packethdr_t *)packet->data;
- memset(hdr, 0, sizeof *hdr);
+ memset(hdr, 0, sizeof(*hdr));
// leave the last byte as 0 to make sure strings are always
// null-terminated if they are longer than the buffer
- strncpy(hdr->destination, destination->name, (sizeof hdr->destination) - 1);
- strncpy(hdr->source, mesh->self->name, (sizeof hdr->source) -1);
+ strncpy(hdr->destination, destination->name, (sizeof(hdr)->destination) - 1);
+ strncpy(hdr->source, mesh->self->name, (sizeof(hdr)->source) -1);
- memcpy(packet->data + sizeof *hdr, data, len);
+ memcpy(packet->data + sizeof(*hdr), data, len);
// Queue it
if(!meshlink_queue_push(&mesh->outpacketqueue, packet)) {
pthread_mutex_lock(&(mesh->mesh_mutex));
*nmemb = mesh->nodes->count;
- result = realloc(nodes, *nmemb * sizeof *nodes);
+ result = realloc(nodes, *nmemb * sizeof(*nodes));
if(result) {
meshlink_node_t **p = result;
pthread_mutex_lock(&(mesh->mesh_mutex));
- snprintf(filename, sizeof filename, "%s" SLASH "invitations", mesh->confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "invitations", mesh->confbase);
if(mkdir(filename, 0700) && errno != EEXIST) {
logger(mesh, MESHLINK_DEBUG, "Could not create directory %s: %s\n", filename, strerror(errno));
meshlink_errno = MESHLINK_ESTORAGE;
continue;
char invname[PATH_MAX];
struct stat st;
- snprintf(invname, sizeof invname, "%s" SLASH "%s", filename, ent->d_name);
+ snprintf(invname, sizeof(invname), "%s" SLASH "%s", filename, ent->d_name);
if(!stat(invname, &st)) {
if(mesh->invitation_key && deadline < st.st_mtime)
count++;
closedir(dir);
- snprintf(filename, sizeof filename, "%s" SLASH "invitations" SLASH "ecdsa_key.priv", mesh->confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "invitations" SLASH "ecdsa_key.priv", mesh->confbase);
// Remove the key if there are no outstanding invitations.
if(!count) {
exit_configuration(&mesh->config);
char portstr[10];
- snprintf(portstr, sizeof portstr, "%d", port);
- portstr[sizeof portstr - 1] = 0;
+ snprintf(portstr, sizeof(portstr), "%d", port);
+ portstr[sizeof(portstr) - 1] = 0;
modify_config_file(mesh, mesh->name, "Port", portstr, true);
// Ensure no host configuration file with that name exists
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
if(!access(filename, F_OK)) {
logger(mesh, MESHLINK_DEBUG, "A host config file for %s already exists!\n", name);
meshlink_errno = MESHLINK_EEXIST;
char buf[18 + strlen(fingerprint)];
char cookiehash[64];
memcpy(buf, cookie, 18);
- memcpy(buf + 18, fingerprint, sizeof buf - 18);
- sha512(buf, sizeof buf, cookiehash);
+ memcpy(buf + 18, fingerprint, sizeof(buf) - 18);
+ sha512(buf, sizeof(buf), cookiehash);
b64encode_urlsafe(cookiehash, cookiehash, 18);
b64encode_urlsafe(cookie, cookie, 18);
free(fingerprint);
// Create a file containing the details of the invitation.
- snprintf(filename, sizeof filename, "%s" SLASH "invitations" SLASH "%s", mesh->confbase, cookiehash);
+ snprintf(filename, sizeof(filename), "%s" SLASH "invitations" SLASH "%s", mesh->confbase, cookiehash);
int ifd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
if(!ifd) {
logger(mesh, MESHLINK_DEBUG, "Could not create invitation file %s: %s\n", filename, strerror(errno));
fprintf(f, "ConnectTo = %s\n", mesh->self->name);
// Copy Broadcast and Mode
- snprintf(filename, sizeof filename, "%s" SLASH "meshlink.conf", mesh->confbase);
+ snprintf(filename, sizeof(filename), "%s" SLASH "meshlink.conf", mesh->confbase);
FILE *tc = fopen(filename, "r");
if(tc) {
char buf[1024];
- while(fgets(buf, sizeof buf, tc)) {
+ while(fgets(buf, sizeof(buf), tc)) {
if((!strncasecmp(buf, "Mode", 4) && strchr(" \t=", buf[4]))
|| (!strncasecmp(buf, "Broadcast", 9) && strchr(" \t=", buf[9]))) {
fputs(buf, f);
fprintf(f, "#---------------------------------------------------------------#\n");
fprintf(f, "Name = %s\n", mesh->self->name);
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->self->name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->self->name);
fcopy(f, filename);
fclose(f);
char hisname[4096] = "";
int code, hismajor, hisminor = 0;
- if(!recvline(mesh, sizeof mesh->line) || sscanf(mesh->line, "%d %s %d.%d", &code, hisname, &hismajor, &hisminor) < 3 || code != 0 || hismajor != PROT_MAJOR || !check_id(hisname) || !recvline(mesh, sizeof mesh->line) || !rstrip(mesh->line) || sscanf(mesh->line, "%d ", &code) != 1 || code != ACK || strlen(mesh->line) < 3) {
+ if(!recvline(mesh, sizeof(mesh)->line) || sscanf(mesh->line, "%d %s %d.%d", &code, hisname, &hismajor, &hisminor) < 3 || code != 0 || hismajor != PROT_MAJOR || !check_id(hisname) || !recvline(mesh, sizeof(mesh)->line) || !rstrip(mesh->line) || sscanf(mesh->line, "%d ", &code) != 1 || code != ACK || strlen(mesh->line) < 3) {
logger(mesh, MESHLINK_DEBUG, "Cannot read greeting from peer\n");
closesocket(mesh->sock);
meshlink_errno = MESHLINK_ENETWORK;
}
// Start an SPTPS session
- if(!sptps_start(&mesh->sptps, mesh, true, false, key, hiskey, meshlink_invitation_label, sizeof meshlink_invitation_label, invitation_send, invitation_receive)) {
+ if(!sptps_start(&mesh->sptps, mesh, true, false, key, hiskey, meshlink_invitation_label, sizeof(meshlink_invitation_label), invitation_send, invitation_receive)) {
meshlink_errno = MESHLINK_EINTERNAL;
pthread_mutex_unlock(&(mesh->mesh_mutex));
return false;
int len;
- while((len = recv(mesh->sock, mesh->line, sizeof mesh->line, 0))) {
+ while((len = recv(mesh->sock, mesh->line, sizeof(mesh)->line, 0))) {
if(len < 0) {
if(errno == EINTR)
continue;
pthread_mutex_lock(&(mesh->mesh_mutex));
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->self->name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, mesh->self->name);
FILE *f = fopen(filename, "r");
if(!f) {
logger(mesh, MESHLINK_DEBUG, "Could not open %s: %s\n", filename, strerror(errno));
}
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, name);
if(!access(filename, F_OK)) {
logger(mesh, MESHLINK_DEBUG, "File %s already exists, not importing\n", filename);
meshlink_errno = MESHLINK_EEXIST;
n++;
// the first *nmemb members of result can be re-used
if(n > *nmemb)
- copy = xzalloc(sizeof *copy);
+ copy = xzalloc(sizeof(*copy));
else
copy = *p;
copy->from = (meshlink_node_t*)e->from;
meshlink_handle_t *mesh = n->mesh;
if(!mesh->channel_accept_cb)
return;
- meshlink_channel_t *channel = xzalloc(sizeof *channel);
+ meshlink_channel_t *channel = xzalloc(sizeof(*channel));
channel->node = n;
channel->c = utcp_connection;
if(mesh->channel_accept_cb(mesh, channel, port, NULL, 0))
return NULL;
}
}
- meshlink_channel_t *channel = xzalloc(sizeof *channel);
+ meshlink_channel_t *channel = xzalloc(sizeof(*channel));
channel->node = n;
channel->receive_cb = cb;
channel->c = utcp_connect_ex(n->utcp, port, channel_recv, channel, flags);
static void __attribute__((constructor)) meshlink_init(void) {
crypto_init();
unsigned int seed;
- randomize(&seed, sizeof seed);
+ randomize(&seed, sizeof(seed));
srand(seed);
}
} meshlink_queue_item_t;
static inline bool meshlink_queue_push(meshlink_queue_t *queue, void *data) {
- meshlink_queue_item_t *item = malloc(sizeof *item);
+ meshlink_queue_item_t *item = malloc(sizeof(*item));
if(!item)
return false;
item->data = data;
int inlen;
char inbuf[MAXBUFSIZE];
- inlen = recv(c->socket, inbuf, sizeof inbuf, 0);
+ inlen = recv(c->socket, inbuf, sizeof(inbuf), 0);
if(inlen <= 0) {
if(!inlen || !errno) {
return true;
}
- if(c->inbuf.len >= sizeof inbuf) {
+ if(c->inbuf.len >= sizeof(inbuf)) {
logger(mesh, MESHLINK_ERROR, "Input buffer full for %s (%s)", c->name, c->hostname);
return false;
} else
void receive_tcppacket(meshlink_handle_t *mesh, connection_t *c, const char *buffer, int len) {
vpn_packet_t outpkt;
- if(len > sizeof outpkt.data)
+ if(len > sizeof(outpkt).data)
return;
outpkt.len = len;
vpn_packet_t pkt;
char *hostname;
sockaddr_t from = {{0}};
- socklen_t fromlen = sizeof from;
+ socklen_t fromlen = sizeof(from);
node_t *n;
int len;
#if defined(SOL_TCP) && defined(TCP_NODELAY)
int nodelay = 1;
- setsockopt(c->socket, SOL_TCP, TCP_NODELAY, (void *)&nodelay, sizeof nodelay);
+ setsockopt(c->socket, SOL_TCP, TCP_NODELAY, (void *)&nodelay, sizeof(nodelay));
#endif
#if defined(SOL_IP) && defined(IP_TOS) && defined(IPTOS_LOWDELAY)
int lowdelay = IPTOS_LOWDELAY;
- setsockopt(c->socket, SOL_IP, IP_TOS, (void *)&lowdelay, sizeof lowdelay);
+ setsockopt(c->socket, SOL_IP, IP_TOS, (void *)&lowdelay, sizeof(lowdelay));
#endif
}
/* Optimize TCP settings */
option = 1;
- setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof option);
+ setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof(option));
#if defined(SOL_IPV6) && defined(IPV6_V6ONLY)
if(sa->sa.sa_family == AF_INET6)
- setsockopt(nfd, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option);
+ setsockopt(nfd, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
#endif
if(bind(nfd, &sa->sa, SALEN(sa->sa))) {
#endif
option = 1;
- setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof option);
- setsockopt(nfd, SOL_SOCKET, SO_BROADCAST, (void *)&option, sizeof option);
+ setsockopt(nfd, SOL_SOCKET, SO_REUSEADDR, (void *)&option, sizeof(option));
+ setsockopt(nfd, SOL_SOCKET, SO_BROADCAST, (void *)&option, sizeof(option));
#if defined(IPPROTO_IPV6) && defined(IPV6_V6ONLY)
if(sa->sa.sa_family == AF_INET6)
- setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option);
+ setsockopt(nfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
#endif
#if defined(IP_DONTFRAG) && !defined(IP_DONTFRAGMENT)
c->status.connecting = false;
int result;
- socklen_t len = sizeof result;
+ socklen_t len = sizeof(result);
getsockopt(c->socket, SOL_SOCKET, SO_ERROR, (void *)&result, &len);
if(!result)
continue;
// Create a new struct addrinfo, and put it at the head of the list.
- struct addrinfo *nai = xzalloc(sizeof *nai + SALEN(e->reverse->address.sa));
+ struct addrinfo *nai = xzalloc(sizeof(*nai) + SALEN(e->reverse->address.sa));
nai->ai_next = ai;
ai = nai;
#if defined(SOL_IPV6) && defined(IPV6_V6ONLY)
int option = 1;
if(c->address.sa.sa_family == AF_INET6)
- setsockopt(c->socket, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof option);
+ setsockopt(c->socket, SOL_IPV6, IPV6_V6ONLY, (void *)&option, sizeof(option));
#endif
bind_to_address(mesh, c);
connection_t *c;
sockaddr_t sa;
int fd;
- socklen_t len = sizeof sa;
+ socklen_t len = sizeof(sa);
fd = accept(l->tcp.fd, &sa.sa, &len);
}
}
- memcpy(&prev_sa, &sa, sizeof sa);
+ memcpy(&prev_sa, &sa, sizeof(sa));
// Check if we get many connections from different hosts
}
if(!found) {
- outgoing_t *outgoing = xzalloc(sizeof *outgoing);
+ outgoing_t *outgoing = xzalloc(sizeof(*outgoing));
outgoing->mesh = mesh;
outgoing->name = name;
list_insert_tail(mesh->outgoings, outgoing);
return;
}
- err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof address, port, sizeof port, NI_NUMERICHOST | NI_NUMERICSERV);
+ err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
if(err) {
logger(NULL, MESHLINK_ERROR, "Error while translating addresses: %s", err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err));
return str;
}
- err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof address, port, sizeof port,
+ err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port),
hostnames ? 0 : (NI_NUMERICHOST | NI_NUMERICSERV));
if(err)
logger(NULL, MESHLINK_ERROR, "Error while looking up hostname: %s", err == EAI_SYSTEM ? strerror(errno) : gai_strerror(err));
return strcmp(a->unknown.port, b->unknown.port);
case AF_INET:
- result = memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof a->in.sin_addr);
+ result = memcmp(&a->in.sin_addr, &b->in.sin_addr, sizeof(a)->in.sin_addr);
if(result)
return result;
- return memcmp(&a->in.sin_port, &b->in.sin_port, sizeof a->in.sin_port);
+ return memcmp(&a->in.sin_port, &b->in.sin_port, sizeof(a)->in.sin_port);
case AF_INET6:
- result = memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof a->in6.sin6_addr);
+ result = memcmp(&a->in6.sin6_addr, &b->in6.sin6_addr, sizeof(a)->in6.sin6_addr);
if(result)
return result;
- return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof a->in6.sin6_port);
+ return memcmp(&a->in6.sin6_port, &b->in6.sin6_port, sizeof(a)->in6.sin6_port);
default:
logger(NULL, MESHLINK_ERROR, "sockaddrcmp() was called with unknown address family %d, exitting!",
}
node_t *new_node(void) {
- node_t *n = xzalloc(sizeof *n);
+ node_t *n = xzalloc(sizeof(*n));
n->edge_tree = new_edge_tree();
n->mtu = MTU;
// opad
memxor(tmp, 0x36 ^ 0x5c, mdlen);
- if(sha512(tmp, sizeof tmp, out) != 0)
+ if(sha512(tmp, sizeof(tmp), out) != 0)
return false;
return true;
while(outlen > 0) {
/* Inner HMAC */
- if(!hmac_sha512(data, sizeof data, secret, secretlen, data))
+ if(!hmac_sha512(data, sizeof(data), secret, secretlen, data))
return false;
/* Outer HMAC */
if(outlen >= mdlen) {
- if(!hmac_sha512(data, sizeof data, secret, secretlen, out))
+ if(!hmac_sha512(data, sizeof(data), secret, secretlen, out))
return false;
out += mdlen;
outlen -= mdlen;
} else {
- if(!hmac_sha512(data, sizeof data, secret, secretlen, hash))
+ if(!hmac_sha512(data, sizeof(data), secret, secretlen, hash))
return false;
memcpy(out, hash, outlen);
out += outlen;
char tmp[len + 1];
memcpy(tmp, request, len);
tmp[len] = '\n';
- broadcast_meta(mesh, from, tmp, sizeof tmp);
+ broadcast_meta(mesh, from, tmp, sizeof(tmp));
}
bool receive_request(meshlink_handle_t *mesh, connection_t *c, const char *request) {
logger(mesh, MESHLINK_DEBUG, "Already seen request");
return true;
} else {
- new = xmalloc(sizeof *new);
+ new = xmalloc(sizeof(*new));
new->request = xstrdup(request);
new->firstseen = mesh->loop.now.tv_sec;
splay_insert(mesh->past_request_tree, new);
memcpy(s4req + 4, &c->address.in.sin_addr, 4);
if(mesh->proxyuser)
memcpy(s4req + 8, mesh->proxyuser, strlen(mesh->proxyuser));
- s4req[sizeof s4req - 1] = 0;
+ s4req[sizeof(s4req) - 1] = 0;
c->tcplen = 8;
- return send_meta(mesh, c, s4req, sizeof s4req);
+ return send_meta(mesh, c, s4req, sizeof(s4req));
}
case PROXY_SOCKS5: {
int len = 3 + 6 + (c->address.sa.sa_family == AF_INET ? 4 : 16);
}
if(i > len)
abort();
- return send_meta(mesh, c, s5req, sizeof s5req);
+ return send_meta(mesh, c, s5req, sizeof(s5req));
}
case PROXY_SOCKS4A:
logger(mesh, MESHLINK_ERROR, "Proxy type not implemented yet");
// Create a new host config file
char filename[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "hosts" SLASH "%s", mesh->confbase, c->name);
+ snprintf(filename, sizeof(filename), "%s" SLASH "hosts" SLASH "%s", mesh->confbase, c->name);
if(!access(filename, F_OK)) {
logger(mesh, MESHLINK_ERROR, "Host config file for %s (%s) already exists!\n", c->name, c->hostname);
return false;
char hashbuf[18 + strlen(fingerprint)];
char cookie[25];
memcpy(hashbuf, data, 18);
- memcpy(hashbuf + 18, fingerprint, sizeof hashbuf - 18);
- sha512(hashbuf, sizeof hashbuf, hash);
+ memcpy(hashbuf + 18, fingerprint, sizeof(hashbuf) - 18);
+ sha512(hashbuf, sizeof(hashbuf), hash);
b64encode_urlsafe(hash, cookie, 18);
free(fingerprint);
char filename[PATH_MAX], usedname[PATH_MAX];
- snprintf(filename, sizeof filename, "%s" SLASH "invitations" SLASH "%s", mesh->confbase, cookie);
- snprintf(usedname, sizeof usedname, "%s" SLASH "invitations" SLASH "%s.used", mesh->confbase, cookie);
+ snprintf(filename, sizeof(filename), "%s" SLASH "invitations" SLASH "%s", mesh->confbase, cookie);
+ snprintf(usedname, sizeof(usedname), "%s" SLASH "invitations" SLASH "%s.used", mesh->confbase, cookie);
// Atomically rename the invitation file
if(rename(filename, usedname)) {
// Read the new node's Name from the file
char buf[1024];
- fgets(buf, sizeof buf, f);
+ fgets(buf, sizeof(buf), f);
if(*buf)
buf[strlen(buf) - 1] = 0;
// Send the node the contents of the invitation file
rewind(f);
size_t result;
- while((result = fread(buf, 1, sizeof buf, f)))
+ while((result = fread(buf, 1, sizeof(buf), f)))
sptps_send_record(&c->sptps, 0, buf, result);
sptps_send_record(&c->sptps, 1, buf, 0);
fclose(f);
c->protocol_minor = 2;
c->allow_request = 1;
- return sptps_start(&c->sptps, c, false, false, mesh->invitation_key, c->ecdsa, meshlink_invitation_label, sizeof meshlink_invitation_label, send_meta_sptps, receive_invitation_sptps);
+ return sptps_start(&c->sptps, c, false, false, mesh->invitation_key, c->ecdsa, meshlink_invitation_label, sizeof(meshlink_invitation_label), send_meta_sptps, receive_invitation_sptps);
}
/* Check if identity is a valid name */
}
c->allow_request = ACK;
- char label[sizeof meshlink_tcp_label + strlen(mesh->self->name) + strlen(c->name) + 2];
+ char label[sizeof(meshlink_tcp_label) + strlen(mesh->self->name) + strlen(c->name) + 2];
if(c->outgoing)
- snprintf(label, sizeof label, "%s %s %s", meshlink_tcp_label, mesh->self->name, c->name);
+ snprintf(label, sizeof(label), "%s %s %s", meshlink_tcp_label, mesh->self->name, c->name);
else
- snprintf(label, sizeof label, "%s %s %s", meshlink_tcp_label, c->name, mesh->self->name);
+ snprintf(label, sizeof(label), "%s %s %s", meshlink_tcp_label, c->name, mesh->self->name);
- return sptps_start(&c->sptps, c, c->outgoing, false, mesh->self->connection->ecdsa, c->ecdsa, label, sizeof label - 1, send_meta_sptps, receive_meta_sptps);
+ return sptps_start(&c->sptps, c, c->outgoing, false, mesh->self->connection->ecdsa, c->ecdsa, label, sizeof(label) - 1, send_meta_sptps, receive_meta_sptps);
}
bool send_ack(meshlink_handle_t *mesh, connection_t *c) {
if(to->sptps.label)
logger(mesh, MESHLINK_DEBUG, "send_req_key(%s) called while sptps->label != NULL!", to->name);
- char label[sizeof meshlink_udp_label + strlen(mesh->self->name) + strlen(to->name) + 2];
- snprintf(label, sizeof label, "%s %s %s", meshlink_udp_label, mesh->self->name, to->name);
+ char label[sizeof(meshlink_udp_label) + strlen(mesh->self->name) + strlen(to->name) + 2];
+ snprintf(label, sizeof(label), "%s %s %s", meshlink_udp_label, mesh->self->name, to->name);
sptps_stop(&to->sptps);
to->status.validkey = false;
to->status.waitingforkey = true;
to->last_req_key = mesh->loop.now.tv_sec;
to->incompression = mesh->self->incompression;
- return sptps_start(&to->sptps, to, true, true, mesh->self->connection->ecdsa, to->ecdsa, label, sizeof label - 1, send_initial_sptps_data, receive_sptps_record);
+ return sptps_start(&to->sptps, to, true, true, mesh->self->connection->ecdsa, to->ecdsa, label, sizeof(label) - 1, send_initial_sptps_data, receive_sptps_record);
}
/* REQ_KEY is overloaded to allow arbitrary requests to be routed between two nodes. */
return true;
}
- char label[sizeof meshlink_udp_label + strlen(from->name) + strlen(mesh->self->name) + 2];
- snprintf(label, sizeof label, "%s %s %s", meshlink_udp_label, from->name, mesh->self->name);
+ char label[sizeof(meshlink_udp_label) + strlen(from->name) + strlen(mesh->self->name) + 2];
+ snprintf(label, sizeof(label), "%s %s %s", meshlink_udp_label, from->name, mesh->self->name);
sptps_stop(&from->sptps);
from->status.validkey = false;
from->status.waitingforkey = true;
from->last_req_key = mesh->loop.now.tv_sec;
- sptps_start(&from->sptps, from, false, true, mesh->self->connection->ecdsa, from->ecdsa, label, sizeof label - 1, send_sptps_data, receive_sptps_record);
+ sptps_start(&from->sptps, from, false, true, mesh->self->connection->ecdsa, from->ecdsa, label, sizeof(label) - 1, send_sptps_data, receive_sptps_record);
sptps_receive_data(&from->sptps, buf, len);
return true;
}
logger(mesh, MESHLINK_DEBUG, "Routing packet from \"%s\" to \"%s\"\n", hdr->source, hdr->destination);
//Check Lenght
- if(!checklength(source, packet, sizeof *hdr))
+ if(!checklength(source, packet, sizeof(*hdr)))
return;
if(owner == NULL) {
}
if(owner == mesh->self) {
- const void *payload = packet->data + sizeof *hdr;
- size_t len = packet->len - sizeof *hdr;
+ const void *payload = packet->data + sizeof(*hdr);
+ size_t len = packet->len - sizeof(*hdr);
char hex[len*2 + 1];
if(mesh->log_level >= MESHLINK_DEBUG)
memcpy(msg + 1 + 2 * (33 + keylen), s->label, s->labellen);
// Sign the result.
- if(!ecdsa_sign(s->mykey, msg, sizeof msg, sig))
+ if(!ecdsa_sign(s->mykey, msg, sizeof(msg), sig))
return error(s, EINVAL, "Failed to sign SIG record");
// Send the SIG exchange record.
- return send_record_priv(s, SPTPS_HANDSHAKE, sig, sizeof sig);
+ return send_record_priv(s, SPTPS_HANDSHAKE, sig, sizeof(sig));
}
// Generate key material from the shared secret created from the ECDHE key exchange.
memcpy(msg + 1 + 2 * (33 + keylen), s->label, s->labellen);
// Verify signature.
- if(!ecdsa_verify(s->hiskey, msg, sizeof msg, data))
+ if(!ecdsa_verify(s->hiskey, msg, sizeof(msg), data))
return error(s, EIO, "Failed to verify SIG record");
// Compute shared secret.
s->ecdh = NULL;
// Generate key material from shared secret.
- if(!generate_key_material(s, shared, sizeof shared))
+ if(!generate_key_material(s, shared, sizeof(shared)))
return false;
free(s->mykex);
return error(s, EINVAL, "Invalid argument to sptps_start()");
// Initialise struct sptps
- memset(s, 0, sizeof *s);
+ memset(s, 0, sizeof(*s));
s->handle = handle;
s->initiator = initiator;
free(s->key);
free(s->label);
free(s->late);
- memset(s, 0, sizeof *s);
+ memset(s, 0, sizeof(*s));
return true;
}
static void receive_data(sptps_t *sptps) {
char buf[4096];
int fd = *(int *)sptps->handle;
- size_t len = recv(fd, buf, sizeof buf, 0);
+ size_t len = recv(fd, buf, sizeof(buf), 0);
if(!sptps_receive_data(sptps, buf, len))
abort();
}
crypto_init();
- randomize(buf1, sizeof buf1);
- randomize(buf2, sizeof buf2);
- randomize(buf3, sizeof buf3);
+ randomize(buf1, sizeof(buf1));
+ randomize(buf2, sizeof(buf2));
+ randomize(buf3, sizeof(buf3));
// Key generation
#endif
struct addrinfo *ai, hint;
- memset(&hint, 0, sizeof hint);
+ memset(&hint, 0, sizeof(hint));
hint.ai_family = AF_UNSPEC;
hint.ai_socktype = datagram ? SOCK_DGRAM : SOCK_STREAM;
}
int one = 1;
- setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof one);
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&one, sizeof(one));
if(initiator) {
if(connect(sock, ai->ai_addr, ai->ai_addrlen)) {
char buf[65536];
struct sockaddr addr;
- socklen_t addrlen = sizeof addr;
+ socklen_t addrlen = sizeof(addr);
- if(recvfrom(sock, buf, sizeof buf, MSG_PEEK, &addr, &addrlen) <= 0) {
+ if(recvfrom(sock, buf, sizeof(buf), MSG_PEEK, &addr, &addrlen) <= 0) {
fprintf(stderr, "Could not read from socket: %s\n", strerror(errno));
return 1;
}
return 1;
if(FD_ISSET(in, &fds)) {
- ssize_t len = read(in, buf, sizeof buf);
+ ssize_t len = read(in, buf, sizeof(buf));
if(len < 0) {
fprintf(stderr, "Could not read from stdin: %s\n", strerror(errno));
return 1;
sptps_force_kex(&s);
if(len > 1)
sptps_send_record(&s, 0, buf, len);
- } else if(!sptps_send_record(&s, buf[0] == '!' ? 1 : 0, buf, (len == 1 && buf[0] == '\n') ? 0 : buf[0] == '*' ? sizeof buf : len))
+ } else if(!sptps_send_record(&s, buf[0] == '!' ? 1 : 0, buf, (len == 1 && buf[0] == '\n') ? 0 : buf[0] == '*' ? sizeof(buf) : len))
return 1;
}
if(FD_ISSET(sock, &fds)) {
- ssize_t len = recv(sock, buf, sizeof buf, 0);
+ ssize_t len = recv(sock, buf, sizeof(buf), 0);
if(len < 0) {
fprintf(stderr, "Could not read from socket: %s\n", strerror(errno));
return 1;
unsigned int bitfield_to_int(const void *bitfield, size_t size) {
unsigned int value = 0;
- if(size > sizeof value)
- size = sizeof value;
+ if(size > sizeof(value))
+ size = sizeof(value);
memcpy(&value, bitfield, size);
return value;
}
static inline int xvasprintf(char **strp, const char *fmt, va_list ap) {
#ifdef HAVE_MINGW
char buf[1024];
- int result = vsnprintf(buf, sizeof buf, fmt, ap);
+ int result = vsnprintf(buf, sizeof(buf), fmt, ap);
if(result < 0)
abort();
*strp = xstrdup(buf);
}
size_t len = strlen(data);
- write(wfd, &len, sizeof len);
+ write(wfd, &len, sizeof(len));
write(wfd, data, len);
free(data);
- read(rfd, &len, sizeof len);
+ read(rfd, &len, sizeof(len));
char indata[len + 1];
read(rfd, indata, len);
indata[len] = 0;
}
size_t len = strlen(data);
- if(write(wfd, &len, sizeof len) <= 0) abort();
+ if(write(wfd, &len, sizeof(len)) <= 0) abort();
if(write(wfd, data, len) <= 0) abort();
free(data);
- read(rfd, &len, sizeof len);
+ read(rfd, &len, sizeof(len));
char indata[len + 1];
read(rfd, indata, len);
indata[len] = 0;
static const char testdata2[] = "Test data 2.";
char sig[MESHLINK_SIGLEN * 2];
- size_t siglen = sizeof sig * 2;
+ size_t siglen = sizeof(sig) * 2;
- if(!meshlink_sign(mesh1, testdata1, sizeof testdata1, sig, &siglen)) {
+ if(!meshlink_sign(mesh1, testdata1, sizeof(testdata1), sig, &siglen)) {
fprintf(stderr, "Signing failed\n");
return 1;
}
return 1;
}
- if(!meshlink_verify(mesh2, foo, testdata1, sizeof testdata1, sig, siglen)) {
+ if(!meshlink_verify(mesh2, foo, testdata1, sizeof(testdata1), sig, siglen)) {
fprintf(stderr, "False negative verification\n");
return 1;
}
// Check that bad signatures are revoked
- if(meshlink_verify(mesh2, foo, testdata1, sizeof testdata1, sig, siglen / 2)) {
+ if(meshlink_verify(mesh2, foo, testdata1, sizeof(testdata1), sig, siglen / 2)) {
fprintf(stderr, "False positive verification with half sized signature\n");
return 1;
}
- if(meshlink_verify(mesh2, foo, testdata1, sizeof testdata1, sig, siglen * 2)) {
+ if(meshlink_verify(mesh2, foo, testdata1, sizeof(testdata1), sig, siglen * 2)) {
fprintf(stderr, "False positive verification with double sized signature\n");
return 1;
}
- if(meshlink_verify(mesh2, foo, testdata2, sizeof testdata2, sig, siglen)) {
+ if(meshlink_verify(mesh2, foo, testdata2, sizeof(testdata2), sig, siglen)) {
fprintf(stderr, "False positive verification with wrong data\n");
return 1;
}
- if(meshlink_verify(mesh2, bar, testdata1, sizeof testdata1, sig, siglen)) {
+ if(meshlink_verify(mesh2, bar, testdata1, sizeof(testdata1), sig, siglen)) {
fprintf(stderr, "False positive verification with wrong signer\n");
return 1;
}