ESCL backend: error in parsing and subsequent serialization of pwg:version string

Scope

Affects the ESCL backend.

Summary

When starting a scan job via ESCL, sane first queries the scanner capabilities and then uses some of that info when starting the scan job. In this process, the pwg:version attribute is handled in a flawed manner that leads to some scanners responding with HTTP 409 Conflict. I can reproduce this error with my HP OfficeJet Pro 6830 but I'm sure many more scanners are affected.

Details

In backend/escl/escl_capabilities.h:435 the contents of the pwg:version xml tag are parsed:

device->version = atof ((const char *)xmlNodeGetContent(node));

In my particular case, the string to be parsed is 2.1. Note that the string is parsed as a float. Note in particular that, if the string was 2.10 instead, it would get converted to the same float. I.e. we are losing information here and can't distinguish between minor versions *.1 and *.10 anymore.

Later, when assembling the payload for starting the new scan job, a query is assembled using the format string defined around backend/escl/escl_newjob:49:

"   <pwg:Version>%.2f</pwg:Version>" \

In my particular case, the float that was parsed from the original string 2.1 gets serialized to 2.10 here. My printer doesn't support that version, so it returns HTTP 409 Conflict.

Suggested solution

I suggest not converting the version to a float but instead storing it verbatim as a string. Then serialize it using %s instead of %.2f.

Assignee Loading
Time tracking Loading