Skip to content

Commit

Permalink
block/curl.c: Set error message string if curl_init_state() fails
Browse files Browse the repository at this point in the history
In curl_open(), the 'out' label assumes that the state->errmsg string
has been set (either by curl_easy_perform() or by manually copying a
string into it); however if curl_init_state() fails we will jump to
that label without setting the string.  Add the missing error string
setup.

(We can't be specific about the cause of failure: the documentation
of curl_easy_init() just says "If this function returns NULL,
something went wrong".)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20220222152341.850419-2-peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
  • Loading branch information
pm215 authored and XanClic committed Mar 7, 2022
1 parent 7e5cdb3 commit 2ea7dfc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions block/curl.c
Expand Up @@ -759,6 +759,8 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
// Get file size

if (curl_init_state(s, state) < 0) {
pstrcpy(state->errmsg, CURL_ERROR_SIZE,
"curl library initialization failed.");
goto out;
}

Expand Down

0 comments on commit 2ea7dfc

Please sign in to comment.