correctly null terminate the process name
PATCH 1/1 correctly null terminate the process name
strncpy() doesn't garentee the copied string will be null terminated if the original is longer than the length to copy.
Signed-off-by Trevor Saunders <[email protected]>
--- os-posix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
os-posix.c +1 -1
@@ -149,8 +149,8 @@ void os_set_proc_name(const char *s)char name[16 ];if (!s)return ; - name[sizeof (name) -1 ] =0 ;strncpy (name, s,sizeof (name)); + name[sizeof (name) -1 ] =0 ;/* Could rewrite argv[0] too, but that's a bit more complicated. This simple way is enough for `top'. */ if (prctl (PR_SET_NAME , name)) {
Signature · 1 line
1.7.7
Am 18.10.2011 04:06, schrieb Trevor Saunders:
Quoted 13 lines
strncpy()doesn't garentee the copied string will be null terminated if the original is longer than the length to copy.Signed-off-by Trevor Saunders<[email protected]>--- os-posix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)os-posix.c +0
-0
os-posix.c void os_set_proc_name(const char *s) · line 156
Quoted 9 lines
os-posix.c +1
-1@@ -149,8 +149,8 @@ void os_set_proc_name(const char *s)char name[16 ];if (!s)return ; - name[sizeof (name) -1 ] =0 ;strncpy (name, s,sizeof (name)); + name[sizeof (name) -1 ] =0 ;/* Could rewrite argv[0] too, but that's a bit more complicated. This simple way is enough for `top'. */ if (prctl (PR_SET_NAME , name)) {
Reviewed-by Stefan Weil <[email protected]>
Quoted 9 lines · Stefan Weil
Am 18.10.2011 04:06, schrieb Trevor Saunders:
Quoted 8 lines
strncpy()doesn't garentee the copied string will be null terminated if the original is longer than the length to copy.Signed-off-by Trevor Saunders<[email protected]>--- os-posix.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 16 lines
Quoted 5 lines
os-posix.c +0
-0os-posix.c void os_set_proc_name(const char *s) · line 156
Quoted 9 lines
os-posix.c +1
-1@@ -149,8 +149,8 @@ void os_set_proc_name(const char *s)char name[16 ];if (!s)return ; - name[sizeof (name) -1 ] =0 ;strncpy (name, s,sizeof (name)); + name[sizeof (name) -1 ] =0 ;/* Could rewrite argv[0] too, but that's a bit more complicated. This simple way is enough for `top'. */ if (prctl (PR_SET_NAME , name)) {Reviewed-by Stefan Weil <[email protected]>
cutils.c has pstrcpy for that.
Signature · 1 line
mailto:[email protected]