mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[common] linux/proctitle: fix off-by-one bug
0884d14bde introduces an off-by-one bug: if
`strlen(title) == totalSize`, then no space will be left for a null terminator.
This commit is contained in:
@@ -124,7 +124,7 @@ void lgSetProcessTitle(const char * title)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
size_t effective = strlen(title);
|
size_t effective = strlen(title);
|
||||||
if (effective > totalSize)
|
if (effective >= totalSize)
|
||||||
effective = totalSize - 1;
|
effective = totalSize - 1;
|
||||||
|
|
||||||
memcpy(buffer, title, effective);
|
memcpy(buffer, title, effective);
|
||||||
|
|||||||
Reference in New Issue
Block a user