Skip to content

division by 0 in processMouse() #45

@xtaran

Description

@xtaran

Reported by @jwilk in Debian as https://bugs.debian.org/1022113:

Package: gpm
Version: 1.20.7-10+b1

gpm crashes when I do "stty cols 1".

GDB says:

   Program received signal SIGFPE, Arithmetic exception.
   0x565eaf44 in processMouse (fd=5, event=0xff9a6980, type=0x565f73e0 <mice+480>, kd_mode=0) at daemon/processmouse.c:173
   173           fine_dx %= (which_mouse->opt_scale);           fine_dy %= (which_mouse->opt_scaley);
   (gdb) print which_mouse->opt_scale
   $1 = 10
   (gdb) print which_mouse->opt_scaley
   $2 = 0
   (gdb) bt
   #0  0x565eaf44 in processMouse (fd=5, event=0xff9a6980, type=0x565f73e0 <mice+480>, kd_mode=0) at daemon/processmouse.c:173
   #1  0x565e9926 in old_main () at daemon/old_main.c:200
   #2  0x565de57c in main (argc=5, argv=0xff9a6b14) at daemon/main.c:33

I think the culprit is the get_console_size() function, which does:

   (which_mouse->opt_scaley)=(which_mouse->opt_scale)*50*maxx/80/maxy;

If maxx is small and maxy is large (200 in my case), you could indeed end up
with opt_scaley set to 0.


-- System Information:
Architecture: i386

Versions of packages gpm depends on:
ii  init-system-helpers  1.65.2
ii  ucf                  3.0043
ii  debconf              1.5.79
ii  libc6                2.35-3
ii  libgpm2              1.20.7-10+b1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions