Re: [PATCH 2/5] kernfs: implement kernfs_walk_and_get()

From
Jan Engelhardt <hidden>
Date
2015-11-17 22:49:00
Also in
cgroups, lkml, netfilter-devel
Reply to
David Miller, 2015-11-17
On Tuesday 2015-11-17 22:20, David Miller wrote:
quoted
+	static char path_buf[PATH_MAX];	/* protected by kernfs_mutex */
+	int len = strlen(path);
...
quoted
+	if (len >= PATH_MAX)
+		return NULL;
+
+	memcpy(path_buf, path, len + 1);
static char path_buf[PATH_MAX];	/* protected by kernfs_mutex */
int len = strlcpy(path_buf, path, PATH_MAX);
...
if (len >= PATH_MAX)
	return NULL;
	if (len < 0 || len >= PATH_MAX)

strlcpy returns a size_t, which, when coerced into an int, could lead to
negative numbers. In that sense, "size_t len" probably seems like an even
better bet yet.
Thread (22 messages) 22 messages, 4 authors, last reply 2015-11-17
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help