[utils] setproctitle: Fix NUL termination (#17724)

Authored by: doe1080
This commit is contained in:
doe1080
2026-09-27 19:40:54 +02:00
committed by GitHub
parent f45f14bd79
commit 39b31b2755
2 changed files with 10 additions and 3 deletions
+9
View File
@@ -107,6 +107,7 @@ from yt_dlp.utils import (
sanitize_filename,
sanitize_path,
sanitize_url,
setproctitle,
shell_quote,
strftime_or_none,
smuggle_url,
@@ -613,6 +614,14 @@ class TestUtil(unittest.TestCase):
self.assertEqual(res_url, url)
self.assertEqual(res_data, {'a': 'b', 'c': 'd'})
@unittest.mock.patch('ctypes.cdll.LoadLibrary')
def test_setproctitle(self, load_library):
for title in ('yt-dlp', 'café'):
with self.subTest(title=title):
setproctitle(title)
buf = load_library.return_value.prctl.call_args.args[1]
self.assertEqual(bytes(buf), title.encode() + b'\0')
def test_shell_quote(self):
args = ['ffmpeg', '-i', 'ñ€ß\'.mp4']
self.assertEqual(