summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffan Karger <steffan@karger.me>2015-04-27 10:12:22 +0200
committerGert Doering <gert@greenie.muc.de>2015-05-02 20:37:18 +0200
commit95f47ab88e1f240984ba3c79f2243ed304b46a94 (patch)
tree8a03e419e7f30301860d6b408f550724e7f503c9
parent9f106991faceff49d0ea506e9cdf7cfc51f78f20 (diff)
downloadopenvpn-95f47ab88e1f240984ba3c79f2243ed304b46a94.tar.gz
openvpn-95f47ab88e1f240984ba3c79f2243ed304b46a94.tar.xz
openvpn-95f47ab88e1f240984ba3c79f2243ed304b46a94.zip
Remove size limit for files inlined in config
As described in trac #484, the current inline file size limit of 10000 bytes is becoming an issue for some users. Since RSA keys and signature sizes are increasing, we need to adjust our limits. As #484 reports, 10000 can be too small for PKCS#12 files with 4K RSA keys. Instead of postponing this issue by increasing the static limit, dynamically increase the buffer size while reading. This keeps the memory usage limited but does allow for larger inlined files. Signed-off-by: Steffan Karger <steffan@karger.me> Acked-by: Gert Doering <gert@greenie.muc.de> Message-Id: <1430122342-11742-1-git-send-email-steffan@karger.me> URL: http://article.gmane.org/gmane.network.openvpn.devel/9607 Signed-off-by: Gert Doering <gert@greenie.muc.de> (cherry picked from commit e473b7c4ce41a450645e0f89579bc25b4a7f7d49)
-rw-r--r--src/openvpn/options.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 496eb5d..6341f7e 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -3752,12 +3752,21 @@ static char *
read_inline_file (struct in_src *is, const char *close_tag, struct gc_arena *gc)
{
char line[OPTION_LINE_SIZE];
- struct buffer buf = alloc_buf (10000);
+ struct buffer buf = alloc_buf (8*OPTION_LINE_SIZE);
char *ret;
while (in_src_get (is, line, sizeof (line)))
{
if (!strncmp (line, close_tag, strlen (close_tag)))
break;
+ if (!buf_safe (&buf, strlen(line)))
+ {
+ /* Increase buffer size */
+ struct buffer buf2 = alloc_buf (buf.capacity * 2);
+ ASSERT (buf_copy (&buf2, &buf));
+ buf_clear (&buf);
+ free_buf (&buf);
+ buf = buf2;
+ }
buf_printf (&buf, "%s", line);
}
ret = string_alloc (BSTR (&buf), gc);