All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH 2/2] devlist: NULL terminate struct devuser fields
@ 2012-09-18 15:13 Namhyung Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2012-09-18 15:13 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 706 bytes --]

As strncpy doesn't guarantee the destination buffer is NULL-
terminated, do it explicitly.

Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
---
 src/devlist.cpp |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/devlist.cpp b/src/devlist.cpp
index 828f47f..71898af 100644
--- a/src/devlist.cpp
+++ b/src/devlist.cpp
@@ -147,7 +147,9 @@ void collect_open_devices(void)
 					continue;
 				dev->pid = strtoull(entry->d_name, NULL, 10);
 				strncpy(dev->device, link, 251);
+				dev->device[251] = '\0';
 				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
+				dev->comm[31] = '\0';
 				target->push_back(dev);
 
 			}
-- 
1.7.9.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Powertop] [PATCH 2/2] devlist: NULL terminate struct devuser fields
@ 2012-09-18 15:16 Sergey Senozhatsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sergey Senozhatsky @ 2012-09-18 15:16 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1222 bytes --]

On (09/19/12 00:13), Namhyung Kim wrote:
> Date: Wed, 19 Sep 2012 00:13:18 +0900
> From: Namhyung Kim <namhyung(a)gmail.com>
> To: powertop(a)lists.01.org
> Subject: [Powertop] [PATCH 2/2] devlist: NULL terminate struct devuser
>  fields
> X-Mailer: git-send-email 1.7.9.2
> 
> As strncpy doesn't guarantee the destination buffer is NULL-
> terminated, do it explicitly.
> 

looks good.

	-ss

> Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
> ---
>  src/devlist.cpp |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/devlist.cpp b/src/devlist.cpp
> index 828f47f..71898af 100644
> --- a/src/devlist.cpp
> +++ b/src/devlist.cpp
> @@ -147,7 +147,9 @@ void collect_open_devices(void)
>  					continue;
>  				dev->pid = strtoull(entry->d_name, NULL, 10);
>  				strncpy(dev->device, link, 251);
> +				dev->device[251] = '\0';
>  				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
> +				dev->comm[31] = '\0';
>  				target->push_back(dev);
>  
>  			}
> -- 
> 1.7.9.2
> 
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Powertop] [PATCH 2/2] devlist: NULL terminate struct devuser fields
@ 2012-09-18 15:42 Chris Ferron
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Ferron @ 2012-09-18 15:42 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 831 bytes --]

On 09/18/2012 08:13 AM, Namhyung Kim wrote:
> As strncpy doesn't guarantee the destination buffer is NULL-
> terminated, do it explicitly.
>
> Signed-off-by: Namhyung Kim <namhyung(a)gmail.com>
> ---
>   src/devlist.cpp |    2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/src/devlist.cpp b/src/devlist.cpp
> index 828f47f..71898af 100644
> --- a/src/devlist.cpp
> +++ b/src/devlist.cpp
> @@ -147,7 +147,9 @@ void collect_open_devices(void)
>   					continue;
>   				dev->pid = strtoull(entry->d_name, NULL, 10);
>   				strncpy(dev->device, link, 251);
> +				dev->device[251] = '\0';
>   				strncpy(dev->comm, read_sysfs_string("/proc/%s/comm", entry->d_name).c_str(), 31);
> +				dev->comm[31] = '\0';
>   				target->push_back(dev);
>   
>   			}
Your patch has been merged
Thank You
-C


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-18 15:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-18 15:42 [Powertop] [PATCH 2/2] devlist: NULL terminate struct devuser fields Chris Ferron
  -- strict thread matches above, loose matches on Subject: below --
2012-09-18 15:16 Sergey Senozhatsky
2012-09-18 15:13 Namhyung Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.