linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Btrfs-progs: set string end sing '\0' for property
@ 2014-04-25  5:50 Liu Bo
  0 siblings, 0 replies; 5+ messages in thread
From: Liu Bo @ 2014-04-25  5:50 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

Set string "xattr_name" 's end with '\0' so that it won't be
violated in memory.

With this fix, xfstest/btrfs/048 can pass on my box.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 props.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/props.c b/props.c
index 4d0aeea..53223a3 100644
--- a/props.c
+++ b/props.c
@@ -135,6 +135,7 @@ static int prop_compression(enum prop_object_type type,
 	}
 	memcpy(xattr_name, XATTR_BTRFS_PREFIX, XATTR_BTRFS_PREFIX_LEN);
 	memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name));
+	xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
 
 	if (value)
 		sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
-- 
1.8.2.1


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

* [PATCH 1/2] Btrfs-progs: set string end sing '\0' for property
@ 2014-04-25  6:28 Liu Bo
  0 siblings, 0 replies; 5+ messages in thread
From: Liu Bo @ 2014-04-25  6:28 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

Set string "xattr_name" 's end with '\0' so that it won't be
violated in memory.

With this fix, xfstest/btrfs/048 can pass on my box.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 props.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/props.c b/props.c
index 4d0aeea..53223a3 100644
--- a/props.c
+++ b/props.c
@@ -135,6 +135,7 @@ static int prop_compression(enum prop_object_type type,
 	}
 	memcpy(xattr_name, XATTR_BTRFS_PREFIX, XATTR_BTRFS_PREFIX_LEN);
 	memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name));
+	xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
 
 	if (value)
 		sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
-- 
1.8.2.1


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

* [PATCH 1/2] Btrfs-progs: set string end sing '\0' for property
@ 2014-04-25  6:29 Liu Bo
  2014-04-25 10:07 ` Filipe David Manana
  0 siblings, 1 reply; 5+ messages in thread
From: Liu Bo @ 2014-04-25  6:29 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe David Borba Manana

Set string "xattr_name" 's end with '\0' so that it won't be
violated in memory.

With this fix, xfstest/btrfs/048 can pass on my box.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
---
 props.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/props.c b/props.c
index 4d0aeea..53223a3 100644
--- a/props.c
+++ b/props.c
@@ -135,6 +135,7 @@ static int prop_compression(enum prop_object_type type,
 	}
 	memcpy(xattr_name, XATTR_BTRFS_PREFIX, XATTR_BTRFS_PREFIX_LEN);
 	memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name));
+	xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
 
 	if (value)
 		sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
-- 
1.8.2.1


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

* Re: [PATCH 1/2] Btrfs-progs: set string end sing '\0' for property
  2014-04-25  6:29 Liu Bo
@ 2014-04-25 10:07 ` Filipe David Manana
  2014-04-25 10:37   ` Liu Bo
  0 siblings, 1 reply; 5+ messages in thread
From: Filipe David Manana @ 2014-04-25 10:07 UTC (permalink / raw)
  To: Liu Bo; +Cc: linux-btrfs@vger.kernel.org

On Fri, Apr 25, 2014 at 7:29 AM, Liu Bo <bo.li.liu@oracle.com> wrote:
> Set string "xattr_name" 's end with '\0' so that it won't be
> violated in memory.
>
> With this fix, xfstest/btrfs/048 can pass on my box.
>
> Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> ---
>  props.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/props.c b/props.c
> index 4d0aeea..53223a3 100644
> --- a/props.c
> +++ b/props.c
> @@ -135,6 +135,7 @@ static int prop_compression(enum prop_object_type type,
>         }
>         memcpy(xattr_name, XATTR_BTRFS_PREFIX, XATTR_BTRFS_PREFIX_LEN);
>         memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name));
> +       xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';

Buffer overrun. You need to sum + 1 to the malloc argument above.

Thanks Liu.

>
>         if (value)
>                 sret = fsetxattr(fd, xattr_name, value, strlen(value), 0);
> --
> 1.8.2.1
>



-- 
Filipe David Manana,

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

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

* Re: [PATCH 1/2] Btrfs-progs: set string end sing '\0' for property
  2014-04-25 10:07 ` Filipe David Manana
@ 2014-04-25 10:37   ` Liu Bo
  0 siblings, 0 replies; 5+ messages in thread
From: Liu Bo @ 2014-04-25 10:37 UTC (permalink / raw)
  To: Filipe David Manana; +Cc: linux-btrfs@vger.kernel.org

On Fri, Apr 25, 2014 at 11:07:49AM +0100, Filipe David Manana wrote:
> On Fri, Apr 25, 2014 at 7:29 AM, Liu Bo <bo.li.liu@oracle.com> wrote:
> > Set string "xattr_name" 's end with '\0' so that it won't be
> > violated in memory.
> >
> > With this fix, xfstest/btrfs/048 can pass on my box.
> >
> > Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
> > ---
> >  props.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/props.c b/props.c
> > index 4d0aeea..53223a3 100644
> > --- a/props.c
> > +++ b/props.c
> > @@ -135,6 +135,7 @@ static int prop_compression(enum prop_object_type type,
> >         }
> >         memcpy(xattr_name, XATTR_BTRFS_PREFIX, XATTR_BTRFS_PREFIX_LEN);
> >         memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name));
> > +       xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0';
> 
> Buffer overrun. You need to sum + 1 to the malloc argument above.

Oops, I made that mistake.

thanks,
-liubo

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

end of thread, other threads:[~2014-04-25 10:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-25  5:50 [PATCH 1/2] Btrfs-progs: set string end sing '\0' for property Liu Bo
  -- strict thread matches above, loose matches on Subject: below --
2014-04-25  6:28 Liu Bo
2014-04-25  6:29 Liu Bo
2014-04-25 10:07 ` Filipe David Manana
2014-04-25 10:37   ` Liu Bo

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).