[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120828202459.GA13638@mwanda>
Date: Tue, 28 Aug 2012 13:24:59 -0700
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Jim Meyering <jim@...ering.net>
Cc: Catalin Marinas <catalin.marinas@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [PATCH] kmemleak: avoid buffer overrun: NUL-terminate
strncpy-copied command
On Fri, Aug 24, 2012 at 01:23:29PM +0200, Jim Meyering wrote:
> In that case, what would you think of a patch to use strcpy instead?
>
> - strncpy(object->comm, current->comm, sizeof(object->comm));
> + strcpy(object->comm, current->comm);
Another option would be to use strlcpy(). It's slightly neater than
the strncpy() followed by a NUL assignment.
>
> Is there a preferred method of adding a static_assert-like statement?
> I see compile_time_assert and a few similar macros, but I haven't
> spotted anything that is used project-wide.
BUILD_BUG_ON().
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists