Your message dated Fri, 25 Jul 2008 17:17:04 +0000
with message-id <[EMAIL PROTECTED]>
and subject line Bug#487475: fixed in xsane 0.995-4
has caused the Debian Bug report #487475,
regarding xsane: assumes options' constraint data is static when it isn't (net 
backend) #2
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [EMAIL PROTECTED]
immediately.)


-- 
487475: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487475
Debian Bug Tracking System
Contact [EMAIL PROTECTED] with problems
--- Begin Message ---
Package: xsane
Version: 0.995-3
Severity: normal
Tags: patch


The problem occurs in xsane when accessing an epson/epkowa driver through
the network backend.  Trying to change options like binary/gray/color,
resolutions, etc., in xsane results in a dialog box with 'Failed to set
value of option mode: invalid argument'.  Playing with various controls
for a while (and dismissing the errors) eventually results in the problem
"fixing itself," after which xsane behaves normally.  There are no problems
when accessing the same driver directly (ie. xsane + epson backend on the
same host).

Please note that this is the same bug referenced here:
  <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=307088>
It was reassigned from xsane to libsane by Julien quite some time ago.
>From what I found, I think it really is a bug in xsane.  (xsane assumes a
memory structure is static but this is not guaranteed when the network
backend is used.)

Here's what I discovered.  A patch that fixes (or is at least an effective
work-around) is attached.

The xsane frontend talks to the local net backend.  The net backend
communicates with the real (epson) backend over the network and builds
a local copy of an opt structure describing the scanner.  xsane then
constructs its menus by walking this structure and creating gtk_menu
objects with label strings stored as direct pointers into the opt
structure.

Unfortunately, while the opt structure is built once and is then stable on
the remote (epson, epkowa, whatever) backend, that memory space is NOT
stable with the net backend.  The pointer returned by the 'opt =
xsane_get_option_descriptor()' call in xsane.c seems to point to a
general purpose memory buffer used by the sanei_* network routines used
by the net backend.

The end result is that it is a bit of a crap-shoot whether
menu_items[].label (a pointer into the opt structure) still points to the
same string as it did when the menu was created.  Since the label string is
used to request changes to the epson backend configuration by name, the
change request only works if the memory hasn't been overwritten by
something else.

The patch fixes this problem by making a copy of the option name and
setting menu_items[].label to point to the new string (removing xsane's
dependence on a volatile memory structure).

See the patch for additional comments.

-- Brad

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (900, 'stable'), (80, 'unstable'), (60, 'experimental')
Architecture: amd64 (x86_64)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.25.6
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages xsane depends on:
ii  libatk1.0-0            1.12.4-3          The ATK accessibility toolkit
ii  libc6                  2.3.6.ds1-13etch5 GNU C Library: Shared libraries
ii  libcairo2              1.2.4-4.1+etch1   The Cairo 2D vector graphics libra
ii  libfontconfig1         2.4.2-1.2         generic font configuration library
ii  libgimp2.0             2.2.13-1etch4     Libraries necessary to Run the GIM
ii  libglib2.0-0           2.12.4-2          The GLib library of C routines
ii  libgtk2.0-0            2.8.20-7          The GTK+ graphical user interface 
ii  libieee1284-3          0.2.10-4          cross-platform library for paralle
ii  libjpeg62              6b-13             The Independent JPEG Group's JPEG 
ii  liblcms1               1.15-1            Color management library
ii  libpango1.0-0          1.14.8-5          Layout and rendering of internatio
ii  libpng12-0             1.2.15~beta5-1    PNG library - runtime
ii  libsane                1.0.18-5          API library for scanners
ii  libtiff4               3.8.2-7           Tag Image File Format (TIFF) libra
ii  libusb-0.1-4           2:0.1.12-5        userspace USB programming library
ii  libx11-6               2:1.0.3-7         X11 client-side library
ii  libxcursor1            1.1.7-4           X cursor management library
ii  libxext6               1:1.0.1-2         X11 miscellaneous extension librar
ii  libxfixes3             1:4.0.1-5         X11 miscellaneous 'fixes' extensio
ii  libxi6                 1:1.0.1-4         X11 Input extension library
ii  libxinerama1           1:1.0.1-4.1       X11 Xinerama extension library
ii  libxrandr2             2:1.1.0.2-5       X11 RandR extension library
ii  libxrender1            1:0.9.1-3         X Rendering Extension client libra
ii  xsane-common           0.995-3           featureful graphical frontend for 
ii  zlib1g                 1:1.2.3-13        compression library - runtime

-- no debconf information
diff -Bburp -x '*.o' -x '*.swp' xsane-0.995/src/xsane-front-gtk.c xsane-0.995.patched/src/xsane-front-gtk.c
--- xsane-0.995/src/xsane-front-gtk.c	2007-05-17 09:35:06.000000000 -0400
+++ xsane-0.995.patched/src/xsane-front-gtk.c	2008-06-01 02:15:51.000000000 -0400
@@ -1024,6 +1033,10 @@ void xsane_option_menu_new(GtkWidget *pa
   }
 
   menu_items = malloc((num_items + 1) * sizeof(menu_items[0]));
+  if(menu_items == NULL) {
+    DBG (1, "out of memory (line %d)\n", __LINE__);
+    exit(SANE_STATUS_NO_MEM);
+  }
 
   menu = gtk_menu_new();
   if (widget_name)
@@ -1047,11 +1060,38 @@ void xsane_option_menu_new(GtkWidget *pa
 
     gtk_widget_show(item);
 
-    menu_items[i].label = str_list[i];
+    /* The net backend seems to scramble then reconstruct the opt structure
+     * that *str_list points to.  menu_items[].label used to a pointer to
+     * something that then gets changed behind its back.
+     * Let's make a copy of the string.  The 255 max length is a backstop in
+     * case there is a problem with the structure.
+     *
+     * FIXME: This is probably a memory leak.  The same menu seems to be
+     * (re-)generated in response to various user actions.  If gtk did the
+     * appropriate free()'s then presumably the *str_list var would have been
+     * destroyed even without the net backend's help.
+     *
+     * FIXME?: The sanei_* net backend is AFAICT undocumented and a real maze.
+     * I have no idea if the opt structure is supposed to be stable over the
+     * net backend...  Maybe there is a bug there?
+     */
+
+     /* menu_items[i].label = str_list[i]; */
+    menu_items[i].label = strndup(str_list[i], 255);
+    if (menu_items[i].label == NULL || strlen(menu_items[i].label) == 255) {
+      fprintf(stderr, "(xsane_option_menu(): menu item too long: '%s'\n", menu_items[i].label);
+      exit(SANE_STATUS_NO_MEM);
+    }
+
     menu_items[i].elem  = elem;
     menu_items[i].index = i;
+    DBG(DBG_proc, "\tmenu_item->%p\tindex=%d\n\tlabel='%s'\n\tmenu_item=%s\n", 
+        menu_items+i,
+        i,
+        str_list[i],
+        menu_items[i].label
+        );
   }
-
   /* add empty element as end of list marker */
   menu_items[i].label = NULL;
   menu_items[i].elem  = NULL;

--- End Message ---
--- Begin Message ---
Source: xsane
Source-Version: 0.995-4

We believe that the bug you reported is fixed in the latest version of
xsane, which is due to be installed in the Debian FTP archive:

xsane-common_0.995-4_all.deb
  to pool/main/x/xsane/xsane-common_0.995-4_all.deb
xsane_0.995-4.diff.gz
  to pool/main/x/xsane/xsane_0.995-4.diff.gz
xsane_0.995-4.dsc
  to pool/main/x/xsane/xsane_0.995-4.dsc
xsane_0.995-4_amd64.deb
  to pool/main/x/xsane/xsane_0.995-4_amd64.deb



A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [EMAIL PROTECTED],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Julien BLACHE <[EMAIL PROTECTED]> (supplier of updated xsane package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [EMAIL PROTECTED])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Fri, 25 Jul 2008 19:04:12 +0200
Source: xsane
Binary: xsane xsane-common
Architecture: source all amd64
Version: 0.995-4
Distribution: unstable
Urgency: low
Maintainer: Julien BLACHE <[EMAIL PROTECTED]>
Changed-By: Julien BLACHE <[EMAIL PROTECTED]>
Description: 
 xsane      - featureful graphical frontend for SANE (Scanner Access Now Easy)
 xsane-common - featureful graphical frontend for SANE (Scanner Access Now Easy)
Closes: 307088 487475 489790
Changes: 
 xsane (0.995-4) unstable; urgency=low
 .
   * debian/control:
     + Bump Standards-Version to 3.8.0 (no changes).
   * debian/xsane.desktop:
     + Remove Encoding key (closes: #489790).
 .
   * debian/patches/05_options_handling_fix.dpatch:
     + Added; duplicate strings for options with a constraint type of
       SANE_CONSTRAINT_STRING_LIST, as the constraint is not guaranteed to
       be stable in memory, and actually isn't when the net backend is used.
       Based on Brad Sawatzky's patch (closes: #487475, #307088).
   * debian/patches/03_gimp_acquire_menu.dpatch:
     + Updated; add missing patch description.
Checksums-Sha1: 
 7c90e10d24d799942425956960ae26667b93fa80 1108 xsane_0.995-4.dsc
 1934b275bc7d67dba764384a38e8aca0015ac722 14112 xsane_0.995-4.diff.gz
 35d7cea2f3c39ce3236ee6b52eed93a008c597a3 1778814 xsane-common_0.995-4_all.deb
 7dea3cb872fd34263b5a9aa150f62a8c5948c1bc 329450 xsane_0.995-4_amd64.deb
Checksums-Sha256: 
 f06b6b616740aca973725bb1d5687fb9acb2d67616749045ea15dd36db9bce37 1108 
xsane_0.995-4.dsc
 d39c0a32aa3c8635305a87ee82f049ffafc2253006cad399f2900d93b4eb672e 14112 
xsane_0.995-4.diff.gz
 9a1e211bba3c048d1fc51d730c7b1fd575b60008df01cca5212773a931f14a7e 1778814 
xsane-common_0.995-4_all.deb
 e33fcad18ce74e4d6bc1e34f66da831e587a70ae9cfde2aa192377a57cde71af 329450 
xsane_0.995-4_amd64.deb
Files: 
 ea65a42a25d02a97d5b9e20a200491e6 1108 graphics optional xsane_0.995-4.dsc
 05d6f6fffa3e75f4ef74d1e6b31190d8 14112 graphics optional xsane_0.995-4.diff.gz
 0c9a28ccb560331d660c940000953116 1778814 graphics optional 
xsane-common_0.995-4_all.deb
 c5a709a5c5bbdc2c8d83b18302cbe7ef 329450 graphics optional 
xsane_0.995-4_amd64.deb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFIiggdzWFP1/XWUWkRAl9yAKCbHiJl+7v4ZFpc5MT7TFGMCl+mtACeInek
CIYiu9afak9rdWpxZnGdMhg=
=aNrS
-----END PGP SIGNATURE-----



--- End Message ---

Reply via email to