Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle a blank stat value #388

Merged
merged 2 commits into from
Mar 25, 2022
Merged

Handle a blank stat value #388

merged 2 commits into from
Mar 25, 2022

Conversation

liquidpele
Copy link
Contributor

A stat with a blank value makes the .stats() call fail with index error.

memcache_connection.stats() 
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 741, in stats 
result = self._fetch_cmd(b'stats', args, False) 
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 921, in _fetch_cmd 
result[key_value[1]] = key_value[2]
IndexError: list index out of range

The line in question we saw that caused this:

b'STAT ep_initfile '

This fixes things to no longer blow up. I chose to use a blank binary string instead of None because I suspect other code might make assumptions about the data being binary strings due to this bug.

Copy link
Collaborator

@jparise jparise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to also add a unit test that covers this case?

@jparise jparise added the bug label Mar 25, 2022
Copy link
Collaborator

@jparise jparise left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thank you!

@jparise jparise merged commit 88e6b63 into pinterest:master Mar 25, 2022
@liquidpele
Copy link
Contributor Author

Awesome, thanks for the fast responses. Any chance for a new release soon that will include this so I can import it into our local company repo from pypi?

jparise pushed a commit that referenced this pull request Apr 1, 2022
A stat with a blank value makes the .stats() call fail with index error.

```
memcache_connection.stats()
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 741, in stats
result = self._fetch_cmd(b'stats', args, False)
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 921, in _fetch_cmd
result[key_value[1]] = key_value[2]
IndexError: list index out of range
```

The line in question we saw that caused this:

```
b'STAT ep_initfile '
```

This fixes things to no longer blow up.   I chose to use a blank binary string instead of None because I suspect other code might make assumptions about the data being binary strings due to this bug.

Co-authored-by: reecepeg <[email protected]>
@jparise
Copy link
Collaborator

jparise commented Apr 1, 2022

Awesome, thanks for the fast responses. Any chance for a new release soon that will include this so I can import it into our local company repo from pypi?

v3.5.2 has been tagged and released on PyPI.

martinnj pushed a commit to martinnj/pymemcache that referenced this pull request Jun 9, 2022
A stat with a blank value makes the .stats() call fail with index error.  

```
memcache_connection.stats() 
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 741, in stats 
result = self._fetch_cmd(b'stats', args, False) 
File "/lib/python3.6/site-packages/pymemcache/client/base.py", line 921, in _fetch_cmd 
result[key_value[1]] = key_value[2]
IndexError: list index out of range
```

The line in question we saw that caused this:

```
b'STAT ep_initfile '
```

This fixes things to no longer blow up.   I chose to use a blank binary string instead of None because I suspect other code might make assumptions about the data being binary strings due to this bug.   

Co-authored-by: reecepeg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants