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  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:	Sun, 12 Oct 2014 22:31:37 +0200
From:	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To:	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
	Masahiro Yamada <yamada.m@...panasonic.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Michal Marek <mmarek@...e.cz>,
	Johannes Berg <johannes.berg@...el.com>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] scripts: docproc.c:  Changed from using strncat to strlcat

Changed from using strncat to strlcat to simplify the code

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
---
 scripts/docproc.c |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/scripts/docproc.c b/scripts/docproc.c
index e267e621..dd1d10a 100644
--- a/scripts/docproc.c
+++ b/scripts/docproc.c
@@ -118,10 +118,10 @@ static void exec_kernel_doc(char **svec)
 			perror("fork");
 			exit(1);
 		case  0:
-			memset(real_filename, 0, sizeof(real_filename));
-			strncat(real_filename, kernsrctree, PATH_MAX);
-			strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
-					PATH_MAX - strlen(real_filename));
+			strlcpy(real_filename, kernsrctree,
+					sizeof(real_filename));
+			strlcat(real_filename, "/" KERNELDOCPATH KERNELDOC,
+					sizeof(real_filename));
 			execvp(real_filename, svec);
 			fprintf(stderr, "exec ");
 			perror(real_filename);
@@ -199,11 +199,9 @@ static void find_export_symbols(char * filename)
 	char line[MAXLINESZ];
 	if (filename_exist(filename) == NULL) {
 		char real_filename[PATH_MAX + 1];
-		memset(real_filename, 0, sizeof(real_filename));
-		strncat(real_filename, srctree, PATH_MAX);
-		strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
-		strncat(real_filename, filename,
-				PATH_MAX - strlen(real_filename));
+		strlcpy(real_filename, srctree, sizeof(real_filename));
+		strlcat(real_filename, "/", sizeof(real_filename));
+		strlcat(real_filename, filename, sizeof(real_filename));
 		sym = add_new_file(filename);
 		fp = fopen(real_filename, "r");
 		if (fp == NULL)	{
@@ -379,10 +377,10 @@ static void find_all_symbols(char *filename)
 		case  0:
 			close(pipefd[0]);
 			dup2(pipefd[1], 1);
-			memset(real_filename, 0, sizeof(real_filename));
-			strncat(real_filename, kernsrctree, PATH_MAX);
-			strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
-					PATH_MAX - strlen(real_filename));
+			strlcpy(real_filename, kernsrctree,
+					sizeof(real_filename));
+			strlcat(real_filename, "/" KERNELDOCPATH KERNELDOC,
+					sizeof(real_filename));
 			execvp(real_filename, vec);
 			fprintf(stderr, "exec ");
 			perror(real_filename);
-- 
1.7.10.4

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