increment/decrement can erroneously report MEMCACHED_UNKNOWN_READ_FAILURE

Bug #1123153 reported by Jason V. Miller
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fix Released
Brian Aker

Bug Description

When calling down into the increment and decrement functions, the response parsing code makes a call to strtoull without resetting errno [1] to zero first. Failing to initialize errno can ultimately cause a value of EINVAL to propagate across the function call, invoke the error handler, and the library will return MEMCACHED_UNKNOWN_READ_FAILURE despite a successful call to the memcached server:

This will be observed by consumers of the library as MEMCACHED_UNKNOWN_READ_FAILURE, followed by the handle becoming unavailable until the retry timeout has expired.

This issue was introduced in libmemcached-1.0.3, and exists in the latest version in the 1.0 branch, libmemcached-1.0.16.

To fix this issue, make sure errno is set to zero before calling strtoull.

To test for this issue, set errno to EINVAL before calling memcached_increment and observe an incorrect return value of MEMCACHED_UNKNOWN_READ_FAILURE.

[1] (see Notes)

Related branches

Brian Aker (brianaker)
Changed in libmemcached:
milestone: none → 1.0.17
assignee: nobody → Brian Aker (brianaker)
importance: Undecided → Medium
status: New → In Progress
Brian Aker (brianaker)
Changed in libmemcached:
status: In Progress → Fix Released
Revision history for this message
Jason V. Miller (jmiller-d) wrote :


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.