]> granicus.if.org Git - libass/commitdiff
fontselect: add bounds checking for memory font stream reads
authorwm4 <wm4@nowhere>
Mon, 31 Aug 2015 10:15:01 +0000 (12:15 +0200)
committerwm4 <wm4@nowhere>
Mon, 31 Aug 2015 10:15:01 +0000 (12:15 +0200)
libass/ass_fontselect.c

index dc143c43c5f3fb57c4e44c00e19bc527f7722d83..02d0bc42d27c3b2a0d8f3a74861f5ea70a7201f9 100644 (file)
@@ -145,6 +145,12 @@ get_data_embedded(void *data, unsigned char *buf, size_t offset, size_t len)
     if (buf == NULL)
         return fd[i].size;
 
+    if (offset >= fd[i].size)
+        return 0;
+
+    if (len > fd[i].size - offset)
+        len = fd[i].size - offset;
+
     memcpy(buf, fd[i].data + offset, len);
     return len;
 }