DPDK patches and discussions
 help / color / mirror / Atom feed
* Re: [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated
  2020-05-08 13:02 [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated Jin Yu
@ 2020-05-08  8:43 ` Ye Xiaolong
  2020-05-15 14:45 ` [dpdk-dev] [PATCH v2] " Jin Yu
  1 sibling, 0 replies; 5+ messages in thread
From: Ye Xiaolong @ 2020-05-08  8:43 UTC (permalink / raw)
  To: Jin Yu; +Cc: Maxime Coquelin, Zhihong Wang, dev

On 05/08, Jin Yu wrote:
>Fix the potential bug.

Could you describe more about the potential bug?

Fixes tag is needed here.

Thanks,
Xiaolong
>
>Signed-off-by: Jin Yu <jin.yu@intel.com>
>---
> examples/vhost_blk/vhost_blk.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
>diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
>index f08473f58..b5ce3332a 100644
>--- a/examples/vhost_blk/vhost_blk.c
>+++ b/examples/vhost_blk/vhost_blk.c
>@@ -757,8 +757,9 @@ vhost_blk_bdev_construct(const char *bdev_name,
> 	if (!bdev)
> 		return NULL;
> 
>-	strncpy(bdev->name, bdev_name, sizeof(bdev->name));
>-	strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name));
>+	snprintf(bdev->name, sizeof(bdev->name), "%s", bdev_name);
>+	snprintf(bdev->product_name, sizeof(bdev->product_name), "%s",
>+		 bdev_serial);
> 	bdev->blocklen = blk_size;
> 	bdev->blockcnt = blk_cnt;
> 	bdev->write_cache = wce_enable;
>-- 
>2.17.2
>

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

* [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated
@ 2020-05-08 13:02 Jin Yu
  2020-05-08  8:43 ` Ye Xiaolong
  2020-05-15 14:45 ` [dpdk-dev] [PATCH v2] " Jin Yu
  0 siblings, 2 replies; 5+ messages in thread
From: Jin Yu @ 2020-05-08 13:02 UTC (permalink / raw)
  To: Maxime Coquelin, Zhihong Wang, Xiaolong Ye; +Cc: dev, Jin Yu

Fix the potential bug.

Signed-off-by: Jin Yu <jin.yu@intel.com>
---
 examples/vhost_blk/vhost_blk.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index f08473f58..b5ce3332a 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -757,8 +757,9 @@ vhost_blk_bdev_construct(const char *bdev_name,
 	if (!bdev)
 		return NULL;
 
-	strncpy(bdev->name, bdev_name, sizeof(bdev->name));
-	strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name));
+	snprintf(bdev->name, sizeof(bdev->name), "%s", bdev_name);
+	snprintf(bdev->product_name, sizeof(bdev->product_name), "%s",
+		 bdev_serial);
 	bdev->blocklen = blk_size;
 	bdev->blockcnt = blk_cnt;
 	bdev->write_cache = wce_enable;
-- 
2.17.2


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

* Re: [dpdk-dev] [PATCH v2] example/vhost_blk: fix buffer not null terminated
  2020-05-15 14:45 ` [dpdk-dev] [PATCH v2] " Jin Yu
@ 2020-05-15  7:02   ` Ye Xiaolong
  2020-05-15  8:39   ` Maxime Coquelin
  1 sibling, 0 replies; 5+ messages in thread
From: Ye Xiaolong @ 2020-05-15  7:02 UTC (permalink / raw)
  To: Jin Yu; +Cc: Maxime Coquelin, Zhihong Wang, dev

On 05/15, Jin Yu wrote:
>In vhost_blk_bdev_construct: The string buffer may not have
>a null terminator if the source string's length is equal to
>the buffer size.
>
>Fixes: 91d3e2d42997 ("examples/vhost_blk: refactor to increase readability")
>Cc: jin.yu@intel.com
>
>Signed-off-by: Jin Yu <jin.yu@intel.com>
>---
>V2 - update the commit message
>---
> examples/vhost_blk/vhost_blk.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
>diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
>index 95a050855..f4c59437a 100644
>--- a/examples/vhost_blk/vhost_blk.c
>+++ b/examples/vhost_blk/vhost_blk.c
>@@ -750,8 +750,9 @@ vhost_blk_bdev_construct(const char *bdev_name,
> 	if (!bdev)
> 		return NULL;
> 
>-	strncpy(bdev->name, bdev_name, sizeof(bdev->name));
>-	strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name));
>+	snprintf(bdev->name, sizeof(bdev->name), "%s", bdev_name);
>+	snprintf(bdev->product_name, sizeof(bdev->product_name), "%s",
>+		 bdev_serial);
> 	bdev->blocklen = blk_size;
> 	bdev->blockcnt = blk_cnt;
> 	bdev->write_cache = wce_enable;
>-- 
>2.17.2
>

Reviewed-by: Xiaolong Ye <xiaolong.ye@intel.com>

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

* Re: [dpdk-dev] [PATCH v2] example/vhost_blk: fix buffer not null terminated
  2020-05-15 14:45 ` [dpdk-dev] [PATCH v2] " Jin Yu
  2020-05-15  7:02   ` Ye Xiaolong
@ 2020-05-15  8:39   ` Maxime Coquelin
  1 sibling, 0 replies; 5+ messages in thread
From: Maxime Coquelin @ 2020-05-15  8:39 UTC (permalink / raw)
  To: Jin Yu, Zhihong Wang, Xiaolong Ye; +Cc: dev



On 5/15/20 4:45 PM, Jin Yu wrote:
> In vhost_blk_bdev_construct: The string buffer may not have
> a null terminator if the source string's length is equal to
> the buffer size.
> 
> Fixes: 91d3e2d42997 ("examples/vhost_blk: refactor to increase readability")
> Cc: jin.yu@intel.com
> 
> Signed-off-by: Jin Yu <jin.yu@intel.com>
> ---
> V2 - update the commit message
> ---
>  examples/vhost_blk/vhost_blk.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Applied to dpdk-next-virtio/master.

Thanks,
Maxime


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

* [dpdk-dev] [PATCH v2] example/vhost_blk: fix buffer not null terminated
  2020-05-08 13:02 [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated Jin Yu
  2020-05-08  8:43 ` Ye Xiaolong
@ 2020-05-15 14:45 ` Jin Yu
  2020-05-15  7:02   ` Ye Xiaolong
  2020-05-15  8:39   ` Maxime Coquelin
  1 sibling, 2 replies; 5+ messages in thread
From: Jin Yu @ 2020-05-15 14:45 UTC (permalink / raw)
  To: Maxime Coquelin, Zhihong Wang, Xiaolong Ye; +Cc: dev, Jin Yu

In vhost_blk_bdev_construct: The string buffer may not have
a null terminator if the source string's length is equal to
the buffer size.

Fixes: 91d3e2d42997 ("examples/vhost_blk: refactor to increase readability")
Cc: jin.yu@intel.com

Signed-off-by: Jin Yu <jin.yu@intel.com>
---
V2 - update the commit message
---
 examples/vhost_blk/vhost_blk.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/examples/vhost_blk/vhost_blk.c b/examples/vhost_blk/vhost_blk.c
index 95a050855..f4c59437a 100644
--- a/examples/vhost_blk/vhost_blk.c
+++ b/examples/vhost_blk/vhost_blk.c
@@ -750,8 +750,9 @@ vhost_blk_bdev_construct(const char *bdev_name,
 	if (!bdev)
 		return NULL;
 
-	strncpy(bdev->name, bdev_name, sizeof(bdev->name));
-	strncpy(bdev->product_name, bdev_serial, sizeof(bdev->product_name));
+	snprintf(bdev->name, sizeof(bdev->name), "%s", bdev_name);
+	snprintf(bdev->product_name, sizeof(bdev->product_name), "%s",
+		 bdev_serial);
 	bdev->blocklen = blk_size;
 	bdev->blockcnt = blk_cnt;
 	bdev->write_cache = wce_enable;
-- 
2.17.2


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

end of thread, other threads:[~2020-05-15  8:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08 13:02 [dpdk-dev] [PATCH] example/vhost_blk: fix buffer not null terminated Jin Yu
2020-05-08  8:43 ` Ye Xiaolong
2020-05-15 14:45 ` [dpdk-dev] [PATCH v2] " Jin Yu
2020-05-15  7:02   ` Ye Xiaolong
2020-05-15  8:39   ` Maxime Coquelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).