Issue16904
Created on 2013-01-09 10:28 by sanyi, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg179429 - (view) | Author: Attila Gerendi (sanyi) | Date: 2013-01-09 10:28 | |
In http.client.HTTPConnection's send(data) method if data has attribute read after is handled correctly as file-like object and sent out successfully the code continues to what should be an else branch (~line 858) and tries to send out again the data. This is harmless in most situations but only by chance and also run's unnecessary code. I propose either to use an else branch for the code after line 858 or simply instead break return at line 853. Cheers, Sanyi |
|||
| msg181017 - (view) | Author: Attila Gerendi (sanyi) | Date: 2013-01-31 13:03 | |
Renamed the report since it's unsafe for sure.
This problem was previously called: Avoid unnecessary and possibly unsafe code from http.client.HTTPConnection.send.
Imagine that the data parameter from HTTPConnection it's a file like object but it's not iterable, maybe some custom data wrapper.
the if hasattr(data, "read"): True branch will correctly send out the response then unnecessary continue to:
try:
self.sock.sendall(data)
except TypeError:
if isinstance(data, collections.Iterable):
for d in data:
self.sock.sendall(d)
else:
raise TypeError("data should be a bytes-like object "
"or an iterable, got %r" % type(data))
and crash!
|
|||
| msg201458 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2013-10-27 13:43 | |
Seems this bug was fixed in issue16658. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:57:40 | admin | set | github: 61108 |
| 2013-10-27 13:43:41 | serhiy.storchaka | set | status: open -> closed superseder: Missing "return" in HTTPConnection.send() messages:
+ msg201458 |
| 2013-01-31 13:03:23 | sanyi | set | type: performance -> crash resolution: remind messages: + msg181017 title: Avoid unnecessary and possibly unsafe code from http.client.HTTPConnection.send -> http.client.HTTPConnection.send double send data |
| 2013-01-09 17:13:12 | orsenthil | set | nosy:
+ orsenthil |
| 2013-01-09 10:28:27 | sanyi | create | |
