aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/sys/vesa/background.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-02-27 12:40:31 -0800
committerH. Peter Anvin <hpa@zytor.com>2008-02-27 12:40:31 -0800
commit48722c47bbdcfe51e905e87ec0d34415506393c5 (patch)
treeb20c6bb0d1f556068eeb813db89892b645bec777 /com32/lib/sys/vesa/background.c
parentbcfd0df3c9778eff358926dffd35f870becff26b (diff)
downloadsyslinux-48722c47bbdcfe51e905e87ec0d34415506393c5.tar.gz
syslinux-48722c47bbdcfe51e905e87ec0d34415506393c5.tar.xz
syslinux-48722c47bbdcfe51e905e87ec0d34415506393c5.zip
Comboot/Com32 changes for unspecified file lengths
Handle unspecified file length for comboot/com32 modules; do changes to the appropriate part of libcom32 to handle this properly.
Diffstat (limited to 'com32/lib/sys/vesa/background.c')
-rw-r--r--com32/lib/sys/vesa/background.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/com32/lib/sys/vesa/background.c b/com32/lib/sys/vesa/background.c
index 3bdda208..f141a6ae 100644
--- a/com32/lib/sys/vesa/background.c
+++ b/com32/lib/sys/vesa/background.c
@@ -33,6 +33,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <minmax.h>
+#include <syslinux/loadfile.h>
#include "vesa.h"
#include "video.h"
@@ -172,19 +173,16 @@ static int jpeg_sig_cmp(uint8_t *bytes, int len)
static int read_jpeg_file(FILE *fp, uint8_t *header, int len)
{
struct jdec_private *jdec = NULL;
- unsigned char *jpeg_file = NULL;
- size_t length_of_file = filesize(fp);
+ void *jpeg_file = NULL;
+ size_t length_of_file;
unsigned int width, height;
int rv = -1;
unsigned char *components[1];
unsigned int bytes_per_row[1];
- jpeg_file = malloc(length_of_file);
- if (!jpeg_file)
- goto err;
-
- memcpy(jpeg_file, header, len);
- if (fread(jpeg_file+len, 1, length_of_file-len, fp) != length_of_file-len)
+ rv = floadfile(fp, &jpeg_file, &length_of_file, header, len);
+ fclose(fp);
+ if (rv)
goto err;
jdec = tinyjpeg_init();