Quiet some harmless PVS Studio warnings.

This commit is contained in:
Todd C. Miller
2022-06-29 10:08:55 -06:00
parent 54ed54d94e
commit b6151781ce
8 changed files with 14 additions and 15 deletions

View File

@@ -69,14 +69,14 @@ expand_buf(struct connection_buffer *buf, unsigned int needed)
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
debug_return_bool(false);
}
if (buf->len - buf->off > 0)
if (buf->len != buf->off)
memcpy(newdata, buf->data + buf->off, buf->len - buf->off);
free(buf->data);
buf->data = newdata;
buf->size = needed;
} else {
/* Just reset existing buffer. */
if (buf->len - buf->off > 0) {
if (buf->len != buf->off) {
memmove(buf->data, buf->data + buf->off,
buf->len - buf->off);
}

View File

@@ -268,7 +268,7 @@ connection_close(struct connection_closure *closure)
/* Connect to the first relay available asynchronously. */
if (!connect_relay(new_closure)) {
sudo_warnx(U_("unable to connect to relay"));
sudo_warnx("%s", U_("unable to connect to relay"));
connection_closure_free(new_closure);
}
}
@@ -1548,12 +1548,12 @@ register_listener(struct server_address *addr, struct sudo_event_base *evbase)
/* TODO: make non-fatal */
if ((l = malloc(sizeof(*l))) == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
l->sock = sock;
l->tls = addr->tls;
l->ev = sudo_ev_alloc(sock, SUDO_EV_READ|SUDO_EV_PERSIST, listener_cb, l);
if (l->ev == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(evbase, l->ev, NULL, false) == -1)
sudo_fatal("%s", U_("unable to add event to queue"));
TAILQ_INSERT_TAIL(&listeners, l, entries);
@@ -1737,7 +1737,7 @@ register_signal(int signo, struct sudo_event_base *base)
ev = sudo_ev_alloc(signo, SUDO_EV_SIGNAL, signal_cb, base);
if (ev == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (sudo_ev_add(base, ev, NULL, false) == -1)
sudo_fatal("%s", U_("unable to add event to queue"));
@@ -1953,7 +1953,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
if ((evbase = sudo_ev_base_alloc()) == NULL)
sudo_fatal(NULL);
sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
/* Initialize listeners. */
if (!server_setup(evbase))

View File

@@ -1029,7 +1029,6 @@ cb_logfile_path(struct logsrvd_config *config, const char *str, size_t offset)
debug_decl(cb_logfile_path, SUDO_DEBUG_UTIL);
if (*str != '/') {
debug_return_bool(false);
sudo_warnx(U_("%s: not a fully qualified path"), str);
debug_return_bool(false);
}
@@ -1761,7 +1760,7 @@ logsrvd_conf_apply(struct logsrvd_config *config)
config->server.tls_ciphers_v12, config->server.tls_ciphers_v13,
config->server.tls_verify);
if (config->server.ssl_ctx == NULL) {
sudo_warnx(U_("unable to initialize server TLS context"));
sudo_warnx("%s", U_("unable to initialize server TLS context"));
debug_return_bool(false);
}
break;
@@ -1781,7 +1780,7 @@ logsrvd_conf_apply(struct logsrvd_config *config)
TLS_RELAY_STR(config, tls_ciphers_v13),
TLS_RELAY_INT(config, tls_verify));
if (config->relay.ssl_ctx == NULL) {
sudo_warnx(U_("unable to initialize relay TLS context"));
sudo_warnx("%s", U_("unable to initialize relay TLS context"));
debug_return_bool(false);
}
break;

View File

@@ -132,7 +132,7 @@ outgoing_queue_cb(int unused, int what, void *v)
success = connect_relay(closure);
if (!success) {
sudo_warnx(U_("unable to connect to relay"));
sudo_warnx("%s", U_("unable to connect to relay"));
connection_close(closure);
}
break;

View File

@@ -1798,7 +1798,7 @@ main(int argc, char *argv[])
goto bad;
if ((evbase = sudo_ev_base_alloc()) == NULL)
sudo_fatal(NULL);
sudo_fatal(U_("%s: %s"), __func__, U_("unable to allocate memory"));
if (testrun)
printf("connecting clients...\n");

View File

@@ -235,7 +235,7 @@ tls_client_setup(int sock, const char *ca_bundle_file, const char *cert_file,
ssl_ctx = init_tls_context(ca_bundle_file, cert_file, key_file,
dhparam_file, ciphers_v12, ciphers_v13, verify_server);
if (ssl_ctx == NULL) {
sudo_warnx(U_("unable to initialize TLS context"));
sudo_warnx("%s", U_("unable to initialize TLS context"));
debug_return_bool(false);
}

View File

@@ -1532,7 +1532,7 @@ handle_log_id(char *id, struct client_closure *closure)
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: remote log ID: %s", __func__, id);
if (closure->iolog_id != NULL) {
if ((closure->iolog_id = strdup(id)) == NULL)
sudo_fatal(NULL);
sudo_fatal(U_("%s: %s"), __func__, U_("unable to allocate memory"));
}
debug_return_bool(true);
}

View File

@@ -361,7 +361,7 @@ intercept_connect(void)
debug_decl(intercept_connect, SUDO_DEBUG_EXEC);
if (intercept_port == 0) {
sudo_warnx(U_("intercept port not set"));
sudo_warnx("%s", U_("intercept port not set"));
goto done;
}