We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7575905 commit 6b03720Copy full SHA for 6b03720
sapi/cli/ps_title.c
@@ -28,6 +28,7 @@
28
* The following code is adopted from the PostgreSQL's ps_status(.h/.c).
29
*/
30
31
+#include <php.h>
32
#ifdef PHP_WIN32
33
#include "config.w32.h"
34
#include <windows.h>
@@ -342,9 +343,8 @@ int set_ps_title(const char* title)
342
343
if (rc != PS_TITLE_SUCCESS)
344
return rc;
345
- strncpy(ps_buffer, title, ps_buffer_size);
346
- ps_buffer[ps_buffer_size - 1] = '\0';
347
- ps_buffer_cur_len = strlen(ps_buffer);
+ size_t title_len = strlcpy(ps_buffer, title, ps_buffer_size);
+ ps_buffer_cur_len = (title_len >= ps_buffer_size) ? ps_buffer_size - 1 : title_len;
348
349
#ifdef PS_USE_SETPROCTITLE
350
setproctitle("%s", ps_buffer);
0 commit comments