version: Signature check shouldn't fail when we can't get the sig size

Getting the size of a file is not always supported by the webserver, so
we should try to assume a value to download the signature. 4k is good enough
for the signature used by default for swupd/mixer.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
Otavio Pontes
2020-03-23 14:51:58 -07:00
parent 41f7cc6c9c
commit 6e95d64b8a
+4 -4
View File
@@ -94,14 +94,14 @@ out:
static int get_sig_inmemory(char *url, struct curl_file_data *tmp_version_sig)
{
static const int sig_size = 4096;
int ret = -1;
char *sig_fname;
string_or_die(&sig_fname, "%s.sig", url);
ret = swupd_curl_query_content_size(sig_fname);
if (ret <= 0) {
warn("Failed to retrieve size for signature file: %s\n", sig_fname);
ret = -ENOENT;
goto exit;
debug("Failed to retrieve size for signature file: %s - assuming %d\n", sig_fname, sig_size);
ret = sig_size;
}
tmp_version_sig->capacity = ret;
@@ -111,7 +111,7 @@ static int get_sig_inmemory(char *url, struct curl_file_data *tmp_version_sig)
ret = swupd_curl_get_file_memory(sig_fname, tmp_version_sig);
if (ret != 0) {
warn("Failed to fetch signature file in memory: %s\n", sig_fname);
debug("Failed to fetch signature file in memory: %s\n", sig_fname);
free_and_clear_pointer(&tmp_version_sig->data);
tmp_version_sig->data = NULL;
ret = -ENOENT;