case 'l':
if (blob_equal(key, "local-host") && ctx->nsections == 1) {
if (blob2buf(val, buf, sizeof(buf)))
- str2sockunion(buf, &sactx->local.host);
+ if (str2sockunion(buf, &sactx->local.host) < 0)
+ zlog_err("VICI: bad strongSwan local-host: %s", buf);
} else if (blob_equal(key, "local-id") && ctx->nsections == 1) {
sactx->local.id = *val;
} else if (blob_equal(key, "local-cert-data") && ctx->nsections == 1) {
case 'r':
if (blob_equal(key, "remote-host") && ctx->nsections == 1) {
if (blob2buf(val, buf, sizeof(buf)))
- str2sockunion(buf, &sactx->remote.host);
+ if (str2sockunion(buf, &sactx->remote.host) < 0)
+ zlog_err("VICI: bad strongSwan remote-host: %s", buf);
} else if (blob_equal(key, "remote-id") && ctx->nsections == 1) {
sactx->remote.id = *val;
} else if (blob_equal(key, "remote-cert-data") && ctx->nsections == 1) {
uint32_t msglen;
uint8_t msgtype;
struct blob name;
+ struct vici_message_ctx ctx;
msglen = zbuf_get_be32(msg);
msgtype = zbuf_get8(msg);
vici_recv_sa(vici, msg, 2);
break;
case VICI_CMD_RESPONSE:
- vici_parse_message(vici, msg, parse_cmd_response, 0);
+ vici_parse_message(vici, msg, parse_cmd_response, &ctx);
break;
case VICI_EVENT_UNKNOWN:
case VICI_CMD_UNKNOWN:
zbuf_put_be16(obuf, len);
zbuf_put(obuf, va_arg(va, void *), len);
break;
- case VICI_END:
- break;
default:
break;
}
memset(&addr, 0, sizeof (struct sockaddr_un));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, path, strlen (path));
+ strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
ret = connect(fd, (struct sockaddr *) &addr, sizeof(addr.sun_family) + strlen(addr.sun_path));
if (ret < 0) {
return -1;
}
- fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+ ret = fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_NONBLOCK);
+ if (ret < 0) {
+ close(fd);
+ return -1;
+ }
return fd;
}