[syslinux:master] com32sys_t inreg shall be zeroified prior intcall

syslinux-bot for Erwan Velu erwan at enovance.com
Thu Jan 23 08:15:04 PST 2014


Commit-ID:  3150c7839640859e8ec6ea0243002309e5f9c068
Gitweb:     http://www.syslinux.org/commit/3150c7839640859e8ec6ea0243002309e5f9c068
Author:     Erwan Velu <erwan at enovance.com>
AuthorDate: Wed, 22 Jan 2014 23:57:12 +0100
Committer:  Erwan Velu <erwan at enovance.com>
CommitDate: Wed, 22 Jan 2014 23:57:12 +0100

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

---
 com32/cmenu/libmenu/com32io.c |  6 ++++++
 com32/gfxboot/gfxboot.c       |  8 ++++++++
 com32/hdt/hdt-common.c        |  2 ++
 com32/lib/syslinux/disk.c     |  1 +
 com32/libupload/ctime.c       |  2 ++
 com32/lua/src/vesa.c          |  3 ++-
 com32/mboot/apm.c             |  2 ++
 com32/mboot/initvesa.c        |  2 ++
 com32/mboot/mem.c             |  2 ++
 com32/modules/meminfo.c       |  2 ++
 com32/modules/poweroff.c      |  3 +++
 com32/modules/pxechn.c        |  1 +
 com32/modules/vesainfo.c      |  2 ++
 com32/sysdump/memmap.c        |  2 ++
 com32/sysdump/vesa.c          |  1 +
 core/bios.c                   | 21 +++++++++++++++++++++
 core/font.c                   |  3 +++
 core/fs/diskio_bios.c         |  2 ++
 core/graphics.c               |  3 +++
 core/localboot.c              |  2 ++
 core/plaincon.c               |  2 ++
 core/pxeboot.c                |  1 +
 core/rawcon.c                 |  1 +
 memdisk/conio.c               |  1 +
 memdisk/setup.c               |  1 +
 25 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/com32/cmenu/libmenu/com32io.c b/com32/cmenu/libmenu/com32io.c
index 8e5016b..6954c43 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 9c07d26..f67132c 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 289d74e..fbb8c98 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 a824acc..5a99bb4 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 56c8efb..a3e8155 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 06649e1..19a1024 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 3f48af7..82b6b60 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 bd869e3..9111ec2 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 6e3995b..e42b70b 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 34b3e91..fc04792 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 8b656ad..3255ac2 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 7f2002d..bd614aa 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 66b121d..a65d02c 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 929873f..48241a7 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 42adc3d..3540fc4 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);
diff --git a/core/bios.c b/core/bios.c
index 25e857b..1dfbbe9 100644
--- a/core/bios.c
+++ b/core/bios.c
@@ -52,6 +52,7 @@ static void bios_get_cursor(uint8_t *x, uint8_t *y)
 static void bios_erase(int x0, int y0, int x1, int y1, uint8_t attribute)
 {
     static com32sys_t ireg;
+    memset(&ireg, 0, sizeof(ireg));
 
     ireg.eax.w[0] = 0x0600;	/* Clear window */
     ireg.ebx.b[1] = attribute;
@@ -67,6 +68,8 @@ static void bios_showcursor(const struct term_state *st)
     static com32sys_t ireg;
     uint16_t cursor = st->cursor ? cursor_type : 0x2020;
 
+    memset(&ireg, 0, sizeof(ireg));
+
     ireg.eax.b[1] = 0x01;
     ireg.ecx.w[0] = cursor;
     __intcall(0x10, &ireg, NULL);
@@ -78,6 +81,8 @@ static void bios_set_cursor(int x, int y, bool visible)
     struct curxy xy = BIOS_CURXY[page];
     static com32sys_t ireg;
 
+    memset(&ireg, 0, sizeof(ireg));
+
     (void)visible;
 
     if (xy.x != x || xy.y != y) {
@@ -93,6 +98,8 @@ static void bios_write_char(uint8_t ch, uint8_t attribute)
 {
     static com32sys_t ireg;
 
+    memset(&ireg, 0, sizeof(ireg));
+
     ireg.eax.b[1] = 0x09;
     ireg.eax.b[0] = ch;
     ireg.ebx.b[1] = BIOS_PAGE;
@@ -105,6 +112,8 @@ static void bios_scroll_up(uint8_t cols, uint8_t rows, uint8_t attribute)
 {
     static com32sys_t ireg;
 
+    memset(&ireg, 0, sizeof(ireg));
+
     ireg.eax.w[0] = 0x0601;
     ireg.ebx.b[1] = attribute;
     ireg.ecx.w[0] = 0;
@@ -117,6 +126,8 @@ static void bios_beep(void)
 {
     static com32sys_t ireg;
 
+    memset(&ireg, 0, sizeof(ireg));
+
     ireg.eax.w[0] = 0x0e07;
     ireg.ebx.b[1] = BIOS_PAGE;
     __intcall(0x10, &ireg, NULL);
@@ -161,9 +172,11 @@ void bios_adv_init(void)
 {
     static com32sys_t reg;
 
+    memset(&reg, 0, sizeof(reg));
     reg.eax.w[0] = 0x0025;
     __intcall(0x22, &reg, &reg);
 
+    memset(&reg, 0, sizeof(reg));
     reg.eax.w[0] = 0x001c;
     __intcall(0x22, &reg, &reg);
     __syslinux_adv_ptr = MK_PTR(reg.es, reg.ebx.w[0]);
@@ -174,6 +187,7 @@ int bios_adv_write(void)
 {
     static com32sys_t reg;
 
+    memset(&reg, 0, sizeof(reg));
     reg.eax.w[0] = 0x001d;
     __intcall(0x22, &reg, &reg);
     return (reg.eflags.l & EFLAGS_CF) ? -1 : 0;
@@ -262,6 +276,7 @@ static int bios_vesacon_set_mode(struct vesa_info *vesa_info, int *px, int *py,
 
 	debug("Found mode: 0x%04x\r\n", mode);
 
+        memset(&rm, 0, sizeof rm);
 	memset(mi, 0, sizeof *mi);
 	rm.eax.w[0] = 0x4F01;	/* Get SVGA mode information */
 	rm.ecx.w[0] = mode;
@@ -357,6 +372,7 @@ static int bios_vesacon_set_mode(struct vesa_info *vesa_info, int *px, int *py,
     mi = &vesa_info->mi;
     mode = bestmode;
 
+    memset(&rm, 0, sizeof rm);
     /* Now set video mode */
     rm.eax.w[0] = 0x4F02;	/* Set SVGA video mode */
     if (mi->mode_attr & 0x0080)
@@ -384,6 +400,7 @@ static void set_window_pos(struct win_info *wi, size_t win_pos)
     if (wi->win_num < 0)
 	return;			/* This should never happen... */
 
+    memset(&ireg, 0, sizeof ireg);
     ireg.eax.w[0] = 0x4F05;
     ireg.ebx.b[0] = wi->win_num;
     ireg.edx.w[0] = win_pos >> wi->win_gshift;
@@ -450,6 +467,7 @@ static inline void check_escapes(void)
 {
 	com32sys_t ireg, oreg;
 
+        memset(&ireg, 0, sizeof ireg);
 	ireg.eax.b[1] = 0x02;	/* Check keyboard flags */
 	__intcall(0x16, &ireg, &oreg);
 
@@ -539,6 +557,7 @@ static int bios_scan_memory(scan_memory_callback_t callback, void *data)
     if (!e820buf)
 	return -1;
 
+    memset(&ireg, 0, sizeof ireg);
     ireg.eax.l = 0xe820;
     ireg.edx.l = 0x534d4150;
     ireg.ebx.l = 0;
@@ -592,6 +611,7 @@ static int bios_scan_memory(scan_memory_callback_t callback, void *data)
 	return 0;
 
     /* Next try INT 15h AX=E801h */
+    memset(&ireg, 0, sizeof ireg);
     ireg.eax.w[0] = 0xe801;
     __intcall(0x15, &ireg, &oreg);
 
@@ -611,6 +631,7 @@ static int bios_scan_memory(scan_memory_callback_t callback, void *data)
     }
 
     /* 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]) {
 	rv = callback(data, (addr_t) 1 << 20, oreg.ecx.w[0] << 10, SMT_FREE);
diff --git a/core/font.c b/core/font.c
index 7dd8be7..508f705 100644
--- a/core/font.c
+++ b/core/font.c
@@ -134,6 +134,7 @@ void use_font(void)
 
 			__intcall(0x10, &ireg, &oreg);
 
+                        memset(&ireg, 0, sizeof(ireg));
 			ireg.ebx.b[0] = 0;
 			ireg.eax.w[0] = 0x1103; /* Select page 0 */
 			__intcall(0x10, &ireg, NULL);
@@ -154,6 +155,8 @@ void bios_adjust_screen(void)
 	volatile uint8_t *vidrows = (volatile uint8_t *)BIOS_vidrows;
 	uint8_t rows, cols;
 
+	memset(&ireg, 0, sizeof(ireg));
+
 	rows = *vidrows;
 	if (!rows) {
 		/*
diff --git a/core/fs/diskio_bios.c b/core/fs/diskio_bios.c
index 9b935fe..eba5a17 100644
--- a/core/fs/diskio_bios.c
+++ b/core/fs/diskio_bios.c
@@ -334,6 +334,7 @@ struct disk *bios_disk_init(void *private)
 	    }
 	}
 
+        memset(&ireg, 0, sizeof ireg);
 	/* Get EBIOS support */
 	ireg.eax.b[1] = 0x41;
 	ireg.ebx.w[0] = 0x55aa;
@@ -352,6 +353,7 @@ struct disk *bios_disk_init(void *private)
 	    /* memset(&edd_params, 0, sizeof edd_params);  */
 	    edd_params.len = sizeof edd_params;
 
+            memset(&ireg, 0, sizeof ireg);
 	    ireg.eax.b[1] = 0x48;
 	    ireg.ds = SEG(&edd_params);
 	    ireg.esi.w[0] = OFFS(&edd_params);
diff --git a/core/graphics.c b/core/graphics.c
index 1efb2fa..471847f 100644
--- a/core/graphics.c
+++ b/core/graphics.c
@@ -94,9 +94,11 @@ static int vgasetmode(void)
 	/*
 	 * Set mode.
 	 */
+	memset(&ireg, 0, sizeof(ireg));
 	ireg.eax.w[0] = 0x0012;	/* Set mode = 640x480 VGA 16 colors */
 	__intcall(0x10, &ireg, &oreg);
 
+	memset(&ireg, 0, sizeof(ireg));
 	ireg.edx.w[0] = (uint32_t)linear_color;
 	ireg.eax.w[0] = 0x1002;	/* Write color registers */
 	__intcall(0x10, &ireg, &oreg);
@@ -339,6 +341,7 @@ static void vgacursorcommon(char data)
 {
 	if (UsingVGA) {
 		com32sys_t ireg;
+                memset(&ireg, 0, sizeof(ireg));
 
 		ireg.eax.b[0] = data;
 		ireg.eax.b[1] = 0x09;
diff --git a/core/localboot.c b/core/localboot.c
index 39ffc8c..04635d4 100644
--- a/core/localboot.c
+++ b/core/localboot.c
@@ -39,6 +39,7 @@ __export void local_boot(int16_t ax)
 	com32sys_t ireg, oreg;
 	int i;
 
+        memset(&ireg, 0, sizeof(ireg));
 	syslinux_force_text_mode();
 
 	writestr(LOCALBOOT_MSG);
@@ -62,6 +63,7 @@ __export void local_boot(int16_t ax)
 	ireg.eax.w[0] = 0;	/* Reset drive */
 	__intcall(0x13, &ireg, NULL);
 
+	memset(&ireg, 0, sizeof(ireg));
 	ireg.eax.w[0] = 0x0201;	/* Read one sector */
 	ireg.ecx.w[0] = 0x0001;	/* C/H/S = 0/0/1 (first sector) */
 	ireg.ebx.w[0] = OFFS(trackbuf);
diff --git a/core/plaincon.c b/core/plaincon.c
index 2b7c4a6..66c259e 100644
--- a/core/plaincon.c
+++ b/core/plaincon.c
@@ -14,6 +14,8 @@ __export void writechr(char data)
 {
 	com32sys_t ireg, oreg;
 
+        memset(&ireg, 0, sizeof ireg);
+        memset(&oreg, 0, sizeof oreg);
 	write_serial(data);	/* write to serial port if needed */
 
 	if (UsingVGA & 0x8)
diff --git a/core/pxeboot.c b/core/pxeboot.c
index b6c9099..d9960d8 100644
--- a/core/pxeboot.c
+++ b/core/pxeboot.c
@@ -24,6 +24,7 @@ extern void local_boot16(void);
 __export void local_boot(uint16_t ax)
 {
     com32sys_t ireg;
+    memset(&ireg, 0, sizeof ireg);
 
     syslinux_force_text_mode();
 
diff --git a/core/rawcon.c b/core/rawcon.c
index 6910a84..4403098 100644
--- a/core/rawcon.c
+++ b/core/rawcon.c
@@ -24,6 +24,7 @@ __export void writechr(char data)
 		bool curxyok = false;
 		uint16_t dx;
 
+                memset(&ireg, 0, sizeof ireg);
 		ireg.ebx.b[1] = *(uint8_t *)BIOS_page;
 		ireg.eax.b[1] = 0x03; /* Read cursor position */
 		__intcall(0x10, &ireg, &oreg);
diff --git a/memdisk/conio.c b/memdisk/conio.c
index d1f0862..33be13b 100644
--- a/memdisk/conio.c
+++ b/memdisk/conio.c
@@ -23,6 +23,7 @@
 int putchar(int ch)
 {
     com32sys_t regs;
+    memset(&regs, 0, sizeof regs);
 
     if (ch == '\n') {
 	/* \n -> \r\n */
diff --git a/memdisk/setup.c b/memdisk/setup.c
index 72c6785..992db58 100644
--- a/memdisk/setup.c
+++ b/memdisk/setup.c
@@ -1223,6 +1223,7 @@ void setup(const struct real_mode_args *rm_args_ptr)
 
     if (getcmditem("pause") != CMD_NOTFOUND) {
 	puts("press any key to boot... ");
+	memset(&regs, 0, sizeof regs);
 	regs.eax.w[0] = 0;
 	intcall(0x16, &regs, NULL);
     }


More information about the Syslinux-commits mailing list