aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorErwan Velu <erwan@enovance.com>2014-01-22 23:57:12 +0100
committerErwan Velu <erwan@enovance.com>2014-01-22 23:57:12 +0100
commit3150c7839640859e8ec6ea0243002309e5f9c068 (patch)
tree275ff162a0252960548013afbe8ff7da7e9cffc0 /com32
parent7a9978f280e1d291f6fac419e7c2a0178e9e5d6b (diff)
downloadsyslinux-3150c7839640859e8ec6ea0243002309e5f9c068.tar.gz
syslinux-3150c7839640859e8ec6ea0243002309e5f9c068.tar.xz
syslinux-3150c7839640859e8ec6ea0243002309e5f9c068.zip
com32sys_t inreg shall be zeroified prior intcall
As per commit f775e740a3a817a4ff5ba26bea99dbfd735456b3, inreg parameters of intcall() shall be zeroified. Having unclean inreg could trigger bad behaviors on some hosts. This patch is about adding memset() calls prior any intcall() : - some intcall didn't had any memset at all - some successive intcall() calls didn't memset inreg in between calls
Diffstat (limited to 'com32')
-rw-r--r--com32/cmenu/libmenu/com32io.c6
-rw-r--r--com32/gfxboot/gfxboot.c8
-rw-r--r--com32/hdt/hdt-common.c2
-rw-r--r--com32/lib/syslinux/disk.c1
-rw-r--r--com32/libupload/ctime.c2
-rw-r--r--com32/lua/src/vesa.c3
-rw-r--r--com32/mboot/apm.c2
-rw-r--r--com32/mboot/initvesa.c2
-rw-r--r--com32/mboot/mem.c2
-rw-r--r--com32/modules/meminfo.c2
-rw-r--r--com32/modules/poweroff.c3
-rw-r--r--com32/modules/pxechn.c1
-rw-r--r--com32/modules/vesainfo.c2
-rw-r--r--com32/sysdump/memmap.c2
-rw-r--r--com32/sysdump/vesa.c1
15 files changed, 38 insertions, 1 deletions
diff --git a/com32/cmenu/libmenu/com32io.c b/com32/cmenu/libmenu/com32io.c
index 8e5016be..6954c438 100644
--- a/com32/cmenu/libmenu/com32io.c
+++ b/com32/cmenu/libmenu/com32io.c
@@ -20,6 +20,7 @@ com32sys_t inreg, outreg; // Global register sets for use
void getpos(char *row, char *col, char page)
{
+ memset(&inreg, 0, sizeof inreg);
REG_AH(inreg) = 0x03;
REG_BH(inreg) = page;
__intcall(0x10, &inreg, &outreg);
@@ -30,6 +31,7 @@ void getpos(char *row, char *col, char page)
char inputc(char *scancode)
{
syslinux_idle(); /* So syslinux can perform periodic activity */
+ memset(&inreg, 0, sizeof inreg);
REG_AH(inreg) = 0x10;
__intcall(0x16, &inreg, &outreg);
if (scancode)
@@ -40,6 +42,7 @@ char inputc(char *scancode)
void getcursorshape(char *start, char *end)
{
char page = 0; // XXX TODO
+ memset(&inreg, 0, sizeof inreg);
REG_AH(inreg) = 0x03;
REG_BH(inreg) = page;
__intcall(0x10, &inreg, &outreg);
@@ -49,6 +52,7 @@ void getcursorshape(char *start, char *end)
void setcursorshape(char start, char end)
{
+ memset(&inreg, 0, sizeof inreg);
REG_AH(inreg) = 0x01;
REG_CH(inreg) = start;
REG_CL(inreg) = end;
@@ -57,6 +61,7 @@ void setcursorshape(char start, char end)
void setvideomode(char mode)
{
+ memset(&inreg, 0, sizeof inreg);
REG_AH(inreg) = 0x00;
REG_AL(inreg) = mode;
__intcall(0x10, &inreg, &outreg);
@@ -65,6 +70,7 @@ void setvideomode(char mode)
// Get char displayed at current position
unsigned char getcharat(char page)
{
+ memset(&inreg, 0, sizeof inreg);
REG_AH(inreg) = 0x08;
REG_BH(inreg) = page;
__intcall(0x16, &inreg, &outreg);
diff --git a/com32/gfxboot/gfxboot.c b/com32/gfxboot/gfxboot.c
index 9c07d263..f67132c1 100644
--- a/com32/gfxboot/gfxboot.c
+++ b/com32/gfxboot/gfxboot.c
@@ -538,6 +538,7 @@ int gfx_init(char *file)
void *lowmem = lowmem_buf;
unsigned lowmem_size = LOWMEM_BUF_SIZE;
+ memset(&r,0,sizeof(r));
progress_active = 0;
printf("Loading %s...\n", file);
@@ -646,6 +647,7 @@ int gfx_menu_init(void)
{
com32sys_t r;
+ memset(&r,0,sizeof(r));
r.esi.l = (uint32_t) &gfx_menu;
__farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_MENU_INIT], &r, &r);
@@ -658,6 +660,7 @@ void gfx_done(void)
{
com32sys_t r;
+ memset(&r,0,sizeof(r));
gfx_progress_done();
__farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_DONE], &r, &r);
@@ -674,6 +677,7 @@ int gfx_input(void)
{
com32sys_t r;
+ memset(&r,0,sizeof(r));
r.edi.l = (uint32_t) cmdline;
r.ecx.l = sizeof cmdline;
r.eax.l = timeout * 182 / 100;
@@ -692,6 +696,7 @@ void gfx_infobox(int type, char *str1, char *str2)
{
com32sys_t r;
+ memset(&r,0,sizeof(r));
r.eax.l = type;
r.esi.l = (uint32_t) str1;
r.edi.l = (uint32_t) str2;
@@ -707,6 +712,7 @@ void gfx_progress_init(ssize_t kernel_size, char *label)
{
com32sys_t r;
+ memset(&r,0,sizeof(r));
if(!progress_active) {
r.eax.l = kernel_size >> gfx_config.sector_shift; // in sectors
r.esi.l = (uint32_t) label;
@@ -722,6 +728,7 @@ void gfx_progress_update(ssize_t advance)
{
com32sys_t r;
+ memset(&r,0,sizeof(r));
if(progress_active) {
r.eax.l = advance >> gfx_config.sector_shift; // in sectors
__farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_PROGRESS_UPDATE], &r, &r);
@@ -734,6 +741,7 @@ void gfx_progress_done(void)
{
com32sys_t r;
+ memset(&r,0,sizeof(r));
if(progress_active) {
__farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_PROGRESS_DONE], &r, &r);
}
diff --git a/com32/hdt/hdt-common.c b/com32/hdt/hdt-common.c
index 289d74e3..fbb8c988 100644
--- a/com32/hdt/hdt-common.c
+++ b/com32/hdt/hdt-common.c
@@ -334,6 +334,7 @@ int detect_vesa(struct s_hardware *hardware)
goto out;
gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
+ memset(&rm, 0, sizeof rm);
rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
rm.edi.w[0] = OFFS(gi);
rm.es = SEG(gi);
@@ -361,6 +362,7 @@ int detect_vesa(struct s_hardware *hardware)
while ((mode = *mode_ptr++) != 0xFFFF) {
+ memset(&rm, 0, sizeof rm);
rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
rm.ecx.w[0] = mode;
rm.edi.w[0] = OFFS(mi);
diff --git a/com32/lib/syslinux/disk.c b/com32/lib/syslinux/disk.c
index a824acc5..5a99bb42 100644
--- a/com32/lib/syslinux/disk.c
+++ b/com32/lib/syslinux/disk.c
@@ -229,6 +229,7 @@ static void *chs_setup(const struct disk_info *const diskinfo, com32sys_t *inreg
h = t % diskinfo->head;
c = t / diskinfo->head;
+ memset(inreg, 0, sizeof *inreg);
inreg->eax.b[0] = count;
inreg->eax.b[1] = op_code;
inreg->ecx.b[1] = c;
diff --git a/com32/libupload/ctime.c b/com32/libupload/ctime.c
index 56c8efb6..a3e8155c 100644
--- a/com32/libupload/ctime.c
+++ b/com32/libupload/ctime.c
@@ -24,9 +24,11 @@ uint32_t posix_time(void)
ir.eax.b[1] = 0x04;
__intcall(0x1A, &ir, &d0);
+ memset(&ir, 0, sizeof ir);
ir.eax.b[1] = 0x02;
__intcall(0x1A, &ir, &t0);
+ memset(&ir, 0, sizeof ir);
ir.eax.b[1] = 0x04;
__intcall(0x1A, &ir, &d1);
diff --git a/com32/lua/src/vesa.c b/com32/lua/src/vesa.c
index 06649e11..19a10242 100644
--- a/com32/lua/src/vesa.c
+++ b/com32/lua/src/vesa.c
@@ -27,7 +27,7 @@ static int vesa_getmodes(lua_State *L)
if (!mi)
goto out;
- memset(&rm, 0, sizeof rm);
+ memset(&rm, 0, sizeof(rm));
memset(gi, 0, sizeof *gi);
gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
@@ -61,6 +61,7 @@ static int vesa_getmodes(lua_State *L)
printf("Found mode: 0x%04x (%dx%dx%d)\n", mode, mi->h_res, mi->v_res, mi->bpp);
+ memset(&rm, 0, sizeof(rm));
memset(mi, 0, sizeof *mi);
rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
rm.ecx.w[0] = mode;
diff --git a/com32/mboot/apm.c b/com32/mboot/apm.c
index 3f48af7c..82b6b608 100644
--- a/com32/mboot/apm.c
+++ b/com32/mboot/apm.c
@@ -50,6 +50,7 @@ void mboot_apm(void)
return; /* 32 bits not supported */
/* Disconnect first, just in case */
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.b[0] = 0x04;
__intcall(0x15, &ireg, &oreg);
@@ -68,6 +69,7 @@ void mboot_apm(void)
/* Redo the installation check as the 32-bit connect;
some BIOSes return different flags this way... */
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.b[0] = 0x00;
__intcall(0x15, &ireg, &oreg);
diff --git a/com32/mboot/initvesa.c b/com32/mboot/initvesa.c
index bd869e3d..9111ec27 100644
--- a/com32/mboot/initvesa.c
+++ b/com32/mboot/initvesa.c
@@ -100,6 +100,7 @@ void set_graphics_mode(const struct multiboot_header *mbh,
while ((mode = *mode_ptr++) != 0xFFFF) {
mode &= 0x1FF; /* The rest are attributes of sorts */
+ memset(&rm, 0, sizeof rm);
memset(mi, 0, sizeof *mi);
rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
rm.ecx.w[0] = mode;
@@ -193,6 +194,7 @@ void set_graphics_mode(const struct multiboot_header *mbh,
mode = bestmode;
/* Now set video mode */
+ memset(&rm, 0, sizeof rm);
rm.eax.w[0] = 0x4F02; /* Set SVGA video mode */
mode |= 0x4000; /* Request linear framebuffer */
rm.ebx.w[0] = mode;
diff --git a/com32/mboot/mem.c b/com32/mboot/mem.c
index 6e3995bf..e42b70ba 100644
--- a/com32/mboot/mem.c
+++ b/com32/mboot/mem.c
@@ -124,6 +124,7 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
ard[0].Type = 1;
/* Next try INT 15h AX=E801h */
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.w[0] = 0xe801;
__intcall(0x15, &ireg, &oreg);
@@ -147,6 +148,7 @@ static int mboot_scan_memory(struct AddrRangeDesc **ardp, uint32_t * dosmem)
}
/* Finally try INT 15h AH=88h */
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.w[0] = 0x8800;
if (!(oreg.eflags.l & EFLAGS_CF) && oreg.eax.w[0]) {
ard[1].size = 20;
diff --git a/com32/modules/meminfo.c b/com32/modules/meminfo.c
index 34b3e91d..fc04792f 100644
--- a/com32/modules/meminfo.c
+++ b/com32/modules/meminfo.c
@@ -110,11 +110,13 @@ static void dump_legacy(void)
ivt[0x15].seg, ivt[0x15].offs, dosram, dosram << 10, oreg.eax.w[0],
oreg.eax.w[0] << 10);
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.b[1] = 0x88;
__intcall(0x15, &ireg, &oreg);
printf("INT 15 88: 0x%04x (%uK) ", oreg.eax.w[0], oreg.eax.w[0]);
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.w[0] = 0xe801;
__intcall(0x15, &ireg, &oreg);
diff --git a/com32/modules/poweroff.c b/com32/modules/poweroff.c
index 8b656ad4..3255ac26 100644
--- a/com32/modules/poweroff.c
+++ b/com32/modules/poweroff.c
@@ -50,6 +50,7 @@ int main()
return 1;
}
+ memset(&inregs, 0, sizeof inregs);
inregs.eax.l = 0x5301; /* APM Real Mode Interface Connect (01h) */
inregs.ebx.l = 0; /* APM BIOS (0000h) */
__intcall(0x15, &inregs, &outregs);
@@ -59,6 +60,7 @@ int main()
return 1;
}
+ memset(&inregs, 0, sizeof inregs);
inregs.eax.l = 0x530e; /* APM Driver Version (0Eh) */
inregs.ebx.l = 0; /* APM BIOS (0000h) */
inregs.ecx.l = 0x101; /* APM Driver version 1.1 */
@@ -74,6 +76,7 @@ int main()
return 1;
}
+ memset(&inregs, 0, sizeof inregs);
inregs.eax.l = 0x5307; /* Set Power State (07h) */
inregs.ebx.l = 1; /* All devices power managed by the APM BIOS */
inregs.ecx.l = 3; /* Power state off */
diff --git a/com32/modules/pxechn.c b/com32/modules/pxechn.c
index 7f2002db..bd614aa9 100644
--- a/com32/modules/pxechn.c
+++ b/com32/modules/pxechn.c
@@ -328,6 +328,7 @@ void pxe_set_regs(struct syslinux_rm_regs *regs)
{
com32sys_t tregs;
+ memset(&tregs,0,sizeof(tregs));
regs->ip = 0x7C00;
/* Plan A uses SS:[SP + 4] */
/* sdi->pxe.stack is a usable pointer, not something that can be nicely
diff --git a/com32/modules/vesainfo.c b/com32/modules/vesainfo.c
index 66b121d7..a65d02c1 100644
--- a/com32/modules/vesainfo.c
+++ b/com32/modules/vesainfo.c
@@ -36,6 +36,7 @@ static void print_modes(void)
gi = &vesa->gi;
mi = &vesa->mi;
+ memset(&rm, 0, sizeof rm);
gi->signature = VBE2_MAGIC; /* Get VBE2 extended data */
rm.eax.w[0] = 0x4F00; /* Get SVGA general information */
rm.edi.w[0] = OFFS(gi);
@@ -63,6 +64,7 @@ static void print_modes(void)
lines = 0;
}
+ memset(&rm, 0, sizeof rm);
rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
rm.ecx.w[0] = mode;
rm.edi.w[0] = OFFS(mi);
diff --git a/com32/sysdump/memmap.c b/com32/sysdump/memmap.c
index 929873fe..48241a7a 100644
--- a/com32/sysdump/memmap.c
+++ b/com32/sysdump/memmap.c
@@ -72,10 +72,12 @@ void dump_memory_map(struct upload_backend *be)
__intcall(0x12, &ireg, &oreg);
cpio_writefile(be, "memmap/12", &oreg, sizeof oreg);
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.b[1] = 0x88;
__intcall(0x15, &ireg, &oreg);
cpio_writefile(be, "memmap/1588", &oreg, sizeof oreg);
+ memset(&ireg, 0, sizeof ireg);
ireg.eax.w[0] = 0xe801;
__intcall(0x15, &ireg, &oreg);
cpio_writefile(be, "memmap/15e801", &oreg, sizeof oreg);
diff --git a/com32/sysdump/vesa.c b/com32/sysdump/vesa.c
index 42adc3da..3540fc44 100644
--- a/com32/sysdump/vesa.c
+++ b/com32/sysdump/vesa.c
@@ -41,6 +41,7 @@ void dump_vesa_tables(struct upload_backend *be)
mode_ptr = GET_PTR(gi.video_mode_ptr);
while ((mode = *mode_ptr++) != 0xFFFF) {
memset(mip, 0, sizeof *mip);
+ memset(&rm, 0, sizeof rm);
rm.eax.w[0] = 0x4F01; /* Get SVGA mode information */
rm.ecx.w[0] = mode;
rm.edi.w[0] = OFFS(mip);