]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-38361: syslog: fixed making default "ident" from sys.argv[0] (GH-16557)
authorVáclav Bartoš <bartos@cesnet.cz>
Tue, 14 Jan 2020 17:57:04 +0000 (18:57 +0100)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 14 Jan 2020 17:57:04 +0000 (09:57 -0800)
The default value of "ident" parameter should be sys.argv[0] with leading path
components stripped, but it contained the last slash, i.e. '/program' instead
of 'program'.

BPO issue: https://bugs.python.org/issue38361

https://bugs.python.org/issue38361

Misc/NEWS.d/next/Library/2019-10-04-09-49-56.bpo-38361.LM4u4T.rst [new file with mode: 0644]
Modules/syslogmodule.c

diff --git a/Misc/NEWS.d/next/Library/2019-10-04-09-49-56.bpo-38361.LM4u4T.rst b/Misc/NEWS.d/next/Library/2019-10-04-09-49-56.bpo-38361.LM4u4T.rst
new file mode 100644 (file)
index 0000000..65186db
--- /dev/null
@@ -0,0 +1 @@
+Fixed an issue where ``ident`` could include a leading path separator when :func:`syslog.openlog` was called without arguments.
\ No newline at end of file
index b2ea73baa1be4862f64eb1f749fa5842d88e56d9..539224f2c5b6792612ca1098e7313297ec6bab47 100644 (file)
@@ -99,7 +99,7 @@ syslog_get_argv(void)
     if (slash == -2)
         return NULL;
     if (slash != -1) {
-        return PyUnicode_Substring(scriptobj, slash, scriptlen);
+        return PyUnicode_Substring(scriptobj, slash + 1, scriptlen);
     } else {
         Py_INCREF(scriptobj);
         return(scriptobj);