Dear Maintainer,
in options.c:792 the modulus of the rotating degrees is checked to
be 0. But this is not triggered if degrees is already zero.
Attached patch should avoid this issue and make xloadimage ignore
the rotate request.

Kind regards,
Bernhard

# Bullseye/testing amd64 qemu VM 2020-10-15


apt update
apt dist-upgrade


apt install systemd-coredump mc htop fakeroot quilt lightdm xserver-xorg 
openbox xterm gdb xloadimage xloadimage-dbgsym
apt build-dep xloadimage


reboot



mkdir /home/benutzer/source/xloadimage/orig -p
cd    /home/benutzer/source/xloadimage/orig
apt source xloadimage
cd




export DISPLAY=:0
ulimit -S -v 10000000
cp /usr/share/obconf/video-display.png . -a
xloadimage -rotate 0 video-display.png




benutzer@debian:~$ ulimit -S -v 1000000
benutzer@debian:~$ xloadimage -rotate 0 video-display.png 
video-display.png is 124x128 PNG image, color type RGB_ALPHA, 8 bit
  Rotating image by 0 degrees...

Memory has been exhausted; operation cannot continue (sorry).







gdb -q --args xloadimage -rotate 0 video-display.png
set width 0
set pagination off
directory /home/benutzer/source/xloadimage/xloadimage-4.1
run


(gdb) bt
#0  __GI___libc_malloc (bytes=47616) at malloc.c:3031
#1  0x0000555555565772 in lmalloc (size=<optimized out>) at new.c:218
#2  0x00005555555659b4 in newTrueImage (width=<optimized out>, height=124) at 
new.c:184
#3  0x000055555556dc03 in rotate (simage=0x55555562d6c0, degrees=4290703186, 
verbose=1) at rotate.c:110
#4  0x0000555555575b2b in doProcessOnImage (image=0x55555562d6c0, 
option=<optimized out>, verbose=<optimized out>) at xloadimage.c:110
#5  0x0000555555575c40 in processImage (image=0x55555562d6c0, 
global_options=<optimized out>, image_options=<optimized out>) at 
xloadimage.c:164
#6  0x0000555555559de6 in main (argc=4, argv=0x7fffffffe5a8) at xloadimage.c:417



Description: Fix memory exhaustion when rotating by zero degrees

Author: Bernhard Übelacker <bernha...@mailbox.org>
Bug-Debian: https://bugs.debian.org/971428
Forwarded: no
Last-Update: 2020-10-15

Index: xloadimage-4.1/options.c
===================================================================
--- xloadimage-4.1.orig/options.c
+++ xloadimage-4.1/options.c
@@ -789,7 +789,7 @@ void processOptions(argc, argv, rglobal,
       if (++a >= argc)
 	optionUsage(ROTATE);
       newopt->info.rotate= getInteger(ROTATE, argv[a]);
-      if (newopt->info.rotate % 90) {
+      if (newopt->info.rotate % 90 || newopt->info.rotate == 0) {
 	fprintf(stderr, "Argument to %s must be a multiple of 90 (ignored)\n",
 		optionName(ROTATE));
 	newopt->type= OPT_IGNORE;

Reply via email to