Merge pull request #28417 from bluca/coverity

Some coverity fixes
This commit is contained in:
Luca Boccassi
2023-07-28 09:56:08 +01:00
committed by GitHub
4 changed files with 15 additions and 2 deletions
+2
View File
@@ -63,6 +63,8 @@ int glob_first(const char *path, char **ret_first) {
return k;
if (ret_first) {
assert(g.gl_pathv && g.gl_pathv[0]);
char *first = strdup(g.gl_pathv[0]);
if (!first)
return log_oom_debug();
+3 -1
View File
@@ -544,9 +544,11 @@ static bool push_str(FormatContext *ctx, SpecifierContext *sp) {
if (sp->wstr && sizeof(wchar_t) == sizeof(char16_t)) {
memcpy(ctx->buf + ctx->n, sp->wstr, sp->len * sizeof(*sp->wstr));
ctx->n += sp->len;
} else
} else {
assert(sp->str || sp->wstr);
for (size_t i = 0; i < sp->len; i++)
ctx->buf[ctx->n++] = sp->str ? sp->str[i] : sp->wstr[i];
}
if (sp->align_left)
push_padding(ctx, ' ', sp->padded_len);
+4 -1
View File
@@ -1627,8 +1627,11 @@ static int message_append_cmdline(sd_bus_message *m, const char *signature, char
p--;
r = signature_element_length(signature, &k);
if (r < 0)
if (r < 0 || k < 2) {
if (r >= 0 && k < 2)
r = -ERANGE;
return log_error_errno(r, "Invalid struct/dict entry signature: %m");
}
{
char s[k-1];
+6
View File
@@ -2027,6 +2027,8 @@ _public_ int sd_bus_message_appendv(
r = signature_element_length(t, &k);
if (r < 0)
return r;
if (k < 2)
return -ERANGE;
{
char s[k - 1];
@@ -3470,6 +3472,8 @@ _public_ int sd_bus_message_readv(
r = signature_element_length(t, &k);
if (r < 0)
return r;
if (k < 2)
return -ERANGE;
{
char s[k - 1];
@@ -3650,6 +3654,8 @@ _public_ int sd_bus_message_skip(sd_bus_message *m, const char *types) {
r = signature_element_length(types, &k);
if (r < 0)
return r;
if (k < 2)
return -ERANGE;
{
char s[k-1];