b64encode(key, key, ECDH_SIZE + siglen);
- bool result = send_request(c, "%d %s", METAKEY, key);
+ return send_request(c, "%d %s", METAKEY, key);
}
bool send_metakey(connection_t *c) {
int cipher, digest, maclength, compression, keylen;
node_t *from, *to;
- if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING" %d",
+ if(sscanf(request, "%*d "MAX_STRING" "MAX_STRING" "MAX_STRING" %d %d %d %d "MAX_STRING" "MAX_STRING,
from_name, to_name, key, &cipher, &digest, &maclength,
&compression, address, port) < 7) {
logger(LOG_ERR, "Got bad %s from %s (%s)", "ANS_KEY", c->name,
bool sendline(int fd, char *format, ...) {
static char buffer[4096];
char *p = buffer;
- size_t blen = 0;
+ int blen = 0;
va_list ap;
va_start(ap, format);
blen = vsnprintf(buffer, sizeof buffer, format, ap);
va_end(ap);
- if(blen < 0 || blen >= sizeof buffer)
+ if(blen < 1 || blen >= sizeof buffer)
return false;
buffer[blen] = '\n';
int result = send(fd, p, blen, 0);
if(result == -1 && errno == EINTR)
continue;
- else if(result <= 0);
+ else if(result <= 0)
return false;
p += result;
blen -= result;
struct addrinfo *res = NULL;
if(getaddrinfo(host, port, &hints, &res) || !res) {
- fprintf(stderr, "Cannot resolve %s port %s: %s", host ?: "localhost", port, strerror(errno));
+ fprintf(stderr, "Cannot resolve %s port %s: %s", host, port, strerror(errno));
return 1;
}
#endif
if(connect(fd, res->ai_addr, res->ai_addrlen) < 0) {
- fprintf(stderr, "Cannot connect to %s port %s: %s\n", host ?: "localhost", port, sockstrerror(sockerrno));
+ fprintf(stderr, "Cannot connect to %s port %s: %s\n", host, port, sockstrerror(sockerrno));
return 1;
}