projects
/
project
/
uclient.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
uclient: Handle memory allocation failure for url
[project/uclient.git]
/
uclient-fetch.c
diff --git
a/uclient-fetch.c
b/uclient-fetch.c
index
dff144b
..
38c9c53
100644
(file)
--- a/
uclient-fetch.c
+++ b/
uclient-fetch.c
@@
-50,7
+50,7
@@
static bool verify = true;
static bool proxy = true;
static bool default_certs = false;
static bool no_output;
static bool proxy = true;
static bool default_certs = false;
static bool no_output;
-static const char *output_file;
+static const char *o
pt_o
utput_file;
static int output_fd = -1;
static int error_ret;
static off_t out_offset;
static int output_fd = -1;
static int error_ret;
static off_t out_offset;
@@
-97,6
+97,7
@@
get_proxy_url(char *url)
static int open_output_file(const char *path, uint64_t resume_offset)
{
static int open_output_file(const char *path, uint64_t resume_offset)
{
+ const char *output_file = opt_output_file;
char *filename = NULL;
int flags;
int ret;
char *filename = NULL;
int flags;
int ret;
@@
-121,6
+122,11
@@
static int open_output_file(const char *path, uint64_t resume_offset)
}
} else {
filename = uclient_get_url_filename(path, "index.html");
}
} else {
filename = uclient_get_url_filename(path, "index.html");
+ if (!filename) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
output_file = filename;
}
output_file = filename;
}
@@
-150,6
+156,7
@@
done:
free:
free(filename);
free:
free(filename);
+out:
return ret;
}
return ret;
}
@@
-367,7
+374,7
@@
static void request_done(struct uclient *cl)
return;
}
return;
}
- if (output_fd >= 0 && !output_file) {
+ if (output_fd >= 0 && !o
pt_o
utput_file) {
close(output_fd);
output_fd = -1;
}
close(output_fd);
output_fd = -1;
}
@@
-493,7
+500,7
@@
static int no_ssl(const char *progname)
{
fprintf(stderr,
"%s: SSL support not available, please install one of the "
{
fprintf(stderr,
"%s: SSL support not available, please install one of the "
- "libustream-
ssl-* librari
es as well as the ca-bundle and "
+ "libustream-
.*[ssl|tls] packag
es as well as the ca-bundle and "
"ca-certificates packages.\n",
progname);
"ca-certificates packages.\n",
progname);
@@
-615,7
+622,7
@@
int main(int argc, char **argv)
user_agent = optarg;
break;
case 'O':
user_agent = optarg;
break;
case 'O':
- output_file = optarg;
+ o
pt_o
utput_file = optarg;
break;
case 'P':
if (chdir(optarg)) {
break;
case 'P':
if (chdir(optarg)) {