aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/Lib/poplib.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.com>2025-06-13 00:05:26 +0300
committershadchin <shadchin@yandex-team.com>2025-06-13 00:35:30 +0300
commit796b9088366b10b4cd42885101fc20c0b5709b07 (patch)
treef287eacb0b95ffd7cabf95b16cafb4788645dc38 /contrib/tools/python3/Lib/poplib.py
parentc72bca862651e507d2ff4980ef7f4ff7267a7227 (diff)
downloadydb-796b9088366b10b4cd42885101fc20c0b5709b07.tar.gz
Update Python 3 to 3.12.10
commit_hash:dd2398e159fe1d72ea6b12da52fccc933a41a785
Diffstat (limited to 'contrib/tools/python3/Lib/poplib.py')
-rw-r--r--contrib/tools/python3/Lib/poplib.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/contrib/tools/python3/Lib/poplib.py b/contrib/tools/python3/Lib/poplib.py
index 81b01385987..9eb662d0000 100644
--- a/contrib/tools/python3/Lib/poplib.py
+++ b/contrib/tools/python3/Lib/poplib.py
@@ -226,8 +226,19 @@ class POP3:
retval = self._shortcmd('STAT')
rets = retval.split()
if self._debugging: print('*stat*', repr(rets))
- numMessages = int(rets[1])
- sizeMessages = int(rets[2])
+
+ # Check if the response has enough elements
+ # RFC 1939 requires at least 3 elements (+OK, message count, mailbox size)
+ # but allows additional data after the required fields
+ if len(rets) < 3:
+ raise error_proto("Invalid STAT response format")
+
+ try:
+ numMessages = int(rets[1])
+ sizeMessages = int(rets[2])
+ except ValueError:
+ raise error_proto("Invalid STAT response data: non-numeric values")
+
return (numMessages, sizeMessages)