produce broken scan image with snapscan S300 scanner

Bug #930552 reported by Hiroshi Miura
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libsane-perl (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

As I described in BTS of gscan2pdf, https://sourceforge.net/tracker/?func=detail&aid=3485387&group_id=174140&atid=868098
 libsane-perl: Sane.xs have a bug when length=0 is returned from backend while sane_read().
It is occured with epjitsu backend driver that is used for Fujitsu SnapScan S300 scanner.

Sane.xs:
------------------
void
sane_read (handle, max_length)
  SANE_Handle handle
  SANE_Int max_length
 INIT:
  SANE_Status status;
                SANE_Byte * data;
                SANE_Int length;
        PPCODE:
  data = malloc (max_length);
  status = sane_read (handle, data, max_length, &length);
         SV* sv = get_sv("Sane::_status", FALSE);
                sv_setiv(sv, status);
                if (status) {
                 XPUSHs(sv_2mortal(newSV(0)));
                 XPUSHs(sv_2mortal(newSViv(0)));
                }
                else {
                 XPUSHs(sv_2mortal(newSVpv(data, length)));
   XPUSHs(sv_2mortal(newSViv(length)));
                }
                free (data);
--------------
when call newSVpv(data, length) with length=0, that means 'auto detect length of string of data'.
But length=0 should treat as 'no data'.

If (const char *)data consist by other than '\0', it happens that no-needed bytes is returned.

That is happend with S300 scaner and gscan2pdf, scanimage-perl, and scanadf-perl utilities.

ProblemType: Bug
DistroRelease: Ubuntu 11.10
Package: libsane-perl 0.03-1build1
ProcVersionSignature: Ubuntu 3.0.0-15.26-generic 3.0.13
Uname: Linux 3.0.0-15-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 1.23-0ubuntu4
Architecture: amd64
Date: Sat Feb 11 15:31:17 2012
InstallationMedia: Ubuntu 10.04 LTS "Lucid Lynx" - Release amd64 (20100429)
ProcEnviron:
 PATH=(custom, user)
 LANG=ja_JP.UTF-8
 SHELL=/bin/bash
SourcePackage: libsane-perl
UpgradeStatus: Upgraded to oneiric on 2011-12-24 (49 days ago)

Related branches

Revision history for this message
Hiroshi Miura (miurahr) wrote :
Revision history for this message
Hiroshi Miura (miurahr) wrote :
Revision history for this message
Hiroshi Miura (miurahr) wrote :

An attached fix solves the problem. using newSVPvn(data, len): if len is zero, Perl will create a zero length string.

Revision history for this message
Jeffrey Ratcliffe (jeffreyratcliffe) wrote :

Thanks for all your work on this. Can you reproduce the problem with the test backend?

I really like to introduce add regression tests when fixing bugs, and it would be good to have one for this.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "libsane-perl-0.03-sane_read-length-0-fix.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Hiroshi Miura (miurahr) wrote :

It is not possile to reproduce the problem without modifing test backend.

I attach my suggestion for sane-backend.

I'm not sure it is good for sane standard...

Revision history for this message
Hiroshi Miura (miurahr) wrote :

this patch for sane-backend may be good enough for zero length test for data.

Revision history for this message
Hiroshi Miura (miurahr) wrote :

regression test code proposal

Revision history for this message
Hiroshi Miura (miurahr) wrote :

previous patch fails with options.t. fix it.

Revision history for this message
Jeffrey Ratcliffe (jeffreyratcliffe) wrote :

I have uploaded Sane-0.04, which includes this patch, to CPAN

Changed in libsane-perl (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package libsane-perl - 0.05-2

---------------
libsane-perl (0.05-2) unstable; urgency=low

  * Disable tests
    Closes: #626019 (FTBFS on various architectures (hanging tests?))

 -- Jeffrey Ratcliffe <email address hidden> Mon, 21 May 2012 21:52:44 +0200

Changed in libsane-perl (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.