[sane-devel] Garbage after device names?

Diego Zuccato diego@otello.alma.unibo.it
Fri, 25 Oct 2002 13:00:23 +0000


Hello.

I'm new to this list (but not to Sane :-) ) and I'm having a strange
problem.
Previously I used an old RedHat + sane-1.0.4 + xsane-0.77 and all was
quite ok.
Now I've upgraded (well, reinstalled from scratch) to Mdk9.0, then
installed (from source) sane-1.0.9 (pre1, then final) and xsane-0.89
(tried 0.88 too).

Well, I noticed that xsane couldn't "remember" device settings.
Investigating a bit I discovered that it gets the wrong device, so it
saves files with trailing spurious characters that change between
executions. At a first look it seemed an xsane problem, but then I could
get a wrong name from scanimage -L (since the spurious characters are
non-printable, a simple screen output was not enough... have had to
redirect to a file and then look at it with mcedit).

At this point, I think that it's a bug either in the SCSI layer (GASP!)
or in sane. Shouldn't sane itself truncate too long device names? That
behaviour is the same that is reproducible with :

#include <stdio.h>
#include <string.h>

int main(void)
{
  int x=0x3031;
  char buff[2];

  strncpy(buff, "ab", 2);
  printf("x=%X\nbuff='%s'\n", x, buff);

  return 0;
}

Made this example so that just looking at the output is enough...

Thanks for your attention.

BYtE,
 Diego.