History

avformat/tls: check for memory allocation failure when setting options

jackarain committed 3 years ago

Commit 4e3916d1 parent 05ea0451 file · +20 −6Browse files

Showing the changes to libavformat (1 of 1 file). Show all

Unified · Split

libavformat/tls.c+20−6
@@ -30,15 +30,18 @@ · 29 unmodified lines
30#include "libavutil/opt.h"30#include "libavutil/opt.h"
31#include "libavutil/parseutils.h"31#include "libavutil/parseutils.h"
32 32
33static void set_options(TLSShared *c, const char *uri)33static int set_options(TLSShared *c, const char *uri)
34{34{
35 char buf[1024];35 char buf[1024];
36 const char *p = strchr(uri, '?');36 const char *p = strchr(uri, '?');
37 if (!p)37 if (!p)
38 return;38 return 0;
39 39
40 if (!c->ca_file && av_find_info_tag(buf, sizeof(buf), "cafile", p))40 if (!c->ca_file && av_find_info_tag(buf, sizeof(buf), "cafile", p)) {
41 c->ca_file = av_strdup(buf);41 c->ca_file = av_strdup(buf);
42 if (!c->ca_file)
43 return AVERROR(ENOMEM);
44 }
42 45
43 if (!c->verify && av_find_info_tag(buf, sizeof(buf), "verify", p)) {46 if (!c->verify && av_find_info_tag(buf, sizeof(buf), "verify", p)) {
44 char *endptr = NULL;47 char *endptr = NULL;
@@ -47,11 +50,19 @@ static void set_options(TLSShared *c, const char *uri) · 2 unmodified lines
47 c->verify = 1;50 c->verify = 1;
48 }51 }
49 52
50 if (!c->cert_file && av_find_info_tag(buf, sizeof(buf), "cert", p))53 if (!c->cert_file && av_find_info_tag(buf, sizeof(buf), "cert", p)) {
51 c->cert_file = av_strdup(buf);54 c->cert_file = av_strdup(buf);
55 if (!c->cert_file)
56 return AVERROR(ENOMEM);
57 }
52 58
53 if (!c->key_file && av_find_info_tag(buf, sizeof(buf), "key", p))59 if (!c->key_file && av_find_info_tag(buf, sizeof(buf), "key", p)) {
54 c->key_file = av_strdup(buf);60 c->key_file = av_strdup(buf);
61 if (!c->key_file)
62 return AVERROR(ENOMEM);
63 }
64
65 return 0;
55}66}
56 67
57int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)68int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options)
@@ -63,8 +74,11 @@ int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AV · 5 unmodified lines
63 const char *proxy_path;74 const char *proxy_path;
64 char *env_http_proxy, *env_no_proxy;75 char *env_http_proxy, *env_no_proxy;
65 int use_proxy;76 int use_proxy;
77 int ret;
66 78
67 set_options(c, uri);79 ret = set_options(c, uri);
80 if (ret < 0)
81 return ret;
68 82
69 if (c->listen)83 if (c->listen)
70 snprintf(opts, sizeof(opts), "?listen=1");84 snprintf(opts, sizeof(opts), "?listen=1");

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t