lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <0113e9e511cec23cb500dfd2944c801dc144200b.1498759904.git.baruch@tkos.co.il>
Date:   Thu, 29 Jun 2017 21:11:44 +0300
From:   Baruch Siach <baruch@...s.co.il>
To:     Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>
Cc:     linux-kernel@...r.kernel.org, Baruch Siach <baruch@...s.co.il>
Subject: [PATCH] trace-cmd: use the standard PATH_MAX macro

Having both local MAX_PATH and standard PATH_MAX macros in the code is
confusing. The fact that the MAX_PATH value varies doesn't help. Use the POSIX
standard PATH_MAX everywhere.

Signed-off-by: Baruch Siach <baruch@...s.co.il>
---
 trace-listen.c |  6 ++----
 trace-record.c |  8 ++++----
 trace-util.c   | 13 +++++--------
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/trace-listen.c b/trace-listen.c
index 838d6bcf3649..0db41fe35db0 100644
--- a/trace-listen.c
+++ b/trace-listen.c
@@ -76,8 +76,6 @@ static void put_temp_file(char *file)
 	free(file);
 }
 
-#define MAX_PATH 1024
-
 static void signal_setup(int sig, sighandler_t handle)
 {
 	struct sigaction action;
@@ -91,9 +89,9 @@ static void signal_setup(int sig, sighandler_t handle)
 
 static void delete_temp_file(const char *host, const char *port, int cpu)
 {
-	char file[MAX_PATH];
+	char file[PATH_MAX];
 
-	snprintf(file, MAX_PATH, TEMP_FILE_STR);
+	snprintf(file, PATH_MAX, TEMP_FILE_STR);
 	unlink(file);
 }
 
diff --git a/trace-record.c b/trace-record.c
index 1b55043e2842..7a513eec2d81 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -44,13 +44,13 @@
 #include <sched.h>
 #include <glob.h>
 #include <errno.h>
+#include <limits.h>
 
 #include "trace-local.h"
 #include "trace-msg.h"
 
 #define _STR(x) #x
 #define STR(x) _STR(x)
-#define MAX_PATH 256
 
 #define TRACE_CTRL	"tracing_on"
 #define TRACE		"trace"
@@ -504,12 +504,12 @@ static void put_temp_file(char *file)
 static void delete_temp_file(struct buffer_instance *instance, int cpu)
 {
 	const char *name = instance->name;
-	char file[MAX_PATH];
+	char file[PATH_MAX];
 
 	if (name)
-		snprintf(file, MAX_PATH, "%s.%s.cpu%d", output_file, name, cpu);
+		snprintf(file, PATH_MAX, "%s.%s.cpu%d", output_file, name, cpu);
 	else
-		snprintf(file, MAX_PATH, "%s.cpu%d", output_file, cpu);
+		snprintf(file, PATH_MAX, "%s.cpu%d", output_file, cpu);
 	unlink(file);
 }
 
diff --git a/trace-util.c b/trace-util.c
index fbf8cea26dda..d464a6199760 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -27,6 +27,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <limits.h>
 #include <sys/mount.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -56,10 +57,6 @@ static struct trace_plugin_options {
 #define _STR(x) #x
 #define STR(x) _STR(x)
 
-#ifndef MAX_PATH
-# define MAX_PATH 1024
-#endif
-
 struct plugin_list {
 	struct plugin_list	*next;
 	char			*name;
@@ -705,7 +702,7 @@ static int mount_tracefs(void)
 char *tracecmd_find_tracing_dir(void)
 {
 	char *debug_str = NULL;
-	char fspath[MAX_PATH+1];
+	char fspath[PATH_MAX+1];
 	char *tracing_dir;
 	char type[100];
 	int use_debug = 0;
@@ -717,7 +714,7 @@ char *tracecmd_find_tracing_dir(void)
 	}
 
 	while (fscanf(fp, "%*s %"
-		      STR(MAX_PATH)
+		      STR(PATH_MAX)
 		      "s %99s %*s %*d %*d\n",
 		      fspath, type) == 2) {
 		if (strcmp(type, "tracefs") == 0)
@@ -735,8 +732,8 @@ char *tracecmd_find_tracing_dir(void)
 	if (strcmp(type, "tracefs") != 0) {
 		if (mount_tracefs() < 0) {
 			if (debug_str) {
-				strncpy(fspath, debug_str, MAX_PATH);
-				fspath[MAX_PATH] = 0;
+				strncpy(fspath, debug_str, PATH_MAX);
+				fspath[PATH_MAX] = 0;
 			} else {
 				if (mount_debugfs() < 0) {
 					warning("debugfs not mounted, please mount");
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ