From 7e98073014bba7a7a46edc530112b08534c15813 Mon Sep 17 00:00:00 2001 From: sebres Date: Thu, 12 Dec 2019 21:41:49 +0100 Subject: [PATCH] amend to f3dbc9dda10e52610e3de26f538b5581fd905505: don't need truncate (if the name with \0 exceeds 16 bytes, the string is silently truncated by prctl). --- fail2ban/helpers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py index 8d981ed6..44574ff8 100644 --- a/fail2ban/helpers.py +++ b/fail2ban/helpers.py @@ -461,14 +461,16 @@ def substituteRecursiveTags(inptags, conditional='', if _libcap: def prctl_set_th_name(name): """Helper to set real thread name (used for identification and diagnostic purposes). + + Side effect: name can be silently truncated to 15 bytes (16 bytes with NTS zero) """ try: if sys.version_info >= (3,): # pragma: 2.x no cover name = name.encode() else: # pragma: 3.x no cover name = bytes(name) - _libcap.prctl(15, name[0:15]) # PR_SET_NAME = 15, name can be up to 15 bytes long (16 bytes with NTS zero) - except: + _libcap.prctl(15, name) # PR_SET_NAME = 15 + except: # pragma: no cover pass else: # pragma: no cover def prctl_set_th_name(name):