diff options
-rw-r--r-- | src/backend_librsvg.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/backend_librsvg.c b/src/backend_librsvg.c index 984a351..8e1ef97 100644 --- a/src/backend_librsvg.c +++ b/src/backend_librsvg.c @@ -126,7 +126,7 @@ static int load_image(struct imv_source *src) static enum backend_result open_path(const char *path, struct imv_source **src) { /* Look for an <SVG> tag near the start of the file */ - char header[128]; + char header[4096]; FILE *f = fopen(path, "rb"); if (!f) { return BACKEND_BAD_PATH; @@ -165,9 +165,13 @@ static enum backend_result open_path(const char *path, struct imv_source **src) static enum backend_result open_memory(void *data, size_t len, struct imv_source **src) { /* Look for an <SVG> tag near the start of the file */ - char header[128]; - memcpy(header, data, sizeof header); - header[(sizeof header) - 1] = 0; + char header[4096]; + size_t header_len = sizeof header; + if (header_len > len) { + header_len = len; + } + memcpy(header, data, header_len); + header[header_len - 1] = 0; if (!strstr(header, "<SVG") && !strstr(header, "<svg")) { return BACKEND_UNSUPPORTED; } |