netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH conntrack-tools] conntrackd: use correct max unix path length
@ 2019-07-15  6:46 Michal Kubecek
  2019-07-15  8:11 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Kubecek @ 2019-07-15  6:46 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

When copying value of "Path" option for unix socket, target buffer size is
UNIX_MAX_PATH so that we must not copy more bytes than that. Also make sure
that the path is null terminated and bail out if user provided path is too
long rather than silently truncate it.

Fixes: ce06fb606906 ("conntrackd: use strncpy() to unix path")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 src/read_config_yy.y | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/read_config_yy.y b/src/read_config_yy.y
index ceba6fc0d242..4311cd6c9a2f 100644
--- a/src/read_config_yy.y
+++ b/src/read_config_yy.y
@@ -689,8 +689,13 @@ unix_options:
 
 unix_option : T_PATH T_PATH_VAL
 {
-	strncpy(conf.local.path, $2, PATH_MAX);
+	strncpy(conf.local.path, $2, UNIX_PATH_MAX);
 	free($2);
+	if (conf.local.path[UNIX_PATH_MAX - 1]) {
+		dlog(LOG_ERR, "UNIX Path is longer than %u characters",
+		     UNIX_PATH_MAX - 1);
+		exit(EXIT_FAILURE);
+	}
 };
 
 unix_option : T_BACKLOG T_NUMBER
-- 
2.22.0


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

* Re: [PATCH conntrack-tools] conntrackd: use correct max unix path length
  2019-07-15  6:46 [PATCH conntrack-tools] conntrackd: use correct max unix path length Michal Kubecek
@ 2019-07-15  8:11 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2019-07-15  8:11 UTC (permalink / raw)
  To: Michal Kubecek; +Cc: netfilter-devel

On Mon, Jul 15, 2019 at 08:46:23AM +0200, Michal Kubecek wrote:
> When copying value of "Path" option for unix socket, target buffer size is
> UNIX_MAX_PATH so that we must not copy more bytes than that. Also make sure
> that the path is null terminated and bail out if user provided path is too
> long rather than silently truncate it.

Applied, thanks Michal.

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

end of thread, other threads:[~2019-07-15  8:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15  6:46 [PATCH conntrack-tools] conntrackd: use correct max unix path length Michal Kubecek
2019-07-15  8:11 ` Pablo Neira Ayuso

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