[patch 1/1] [ppc64-diag] hardening

[email protected] Tue, 25 Mar 2014 14:19:42 +0100
Newsgroups gmane.linux.tools.diag.devel
Message-ID <[email protected]>
--===============4107116188408576587==
Content-Disposition: inline; filename=hardening

hardening

Signed-off-by: Frédéric Bonnard <[email protected]>
--- a/rtas_errd/epow.c
+++ b/rtas_errd/epow.c
@@ -109,7 +109,7 @@
 	va_end(ap);
 
 	log_msg(event, buf);
-	snprintf(event->addl_text, ADDL_TEXT_MAX, buf);
+	snprintf(event->addl_text, ADDL_TEXT_MAX, "%s", buf);
 }
 
 /**
--- a/rtas_errd/dump.c
+++ b/rtas_errd/dump.c
@@ -161,7 +161,7 @@
 		goto scanlog_error;
 	}
 
-	out = open(scanlog_filename, O_WRONLY | O_CREAT | O_TRUNC);
+	out = open(scanlog_filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
 	if (out <= 0) {
 		log_msg(NULL, "Could not open %s for writing, %s", 
 			scanlog_filename, strerror(errno));
--- a/rtas_errd/files.c
+++ b/rtas_errd/files.c
@@ -671,7 +671,7 @@
 	va_end(ap);
 
 	len = reformat_msg(buf);
-	fprintf(stdout, buf);
+	fprintf(stdout, "%s", buf);
 	fflush(stdout);
 }
 
--- a/rtas_errd/config.c
+++ b/rtas_errd/config.c
@@ -79,7 +79,7 @@
 			 * started then skip ahead to the next line and
 			 * return that point as the end of the search.
 			 */
-			snprintf(tok, str - start + 1, start);
+			snprintf(tok, str - start + 1, "%s", start);
 			
 			while ((str < str_end) && (*str++ != '\n'));
 			(*line_no)++;
@@ -97,7 +97,7 @@
 				break;
 			}
 
-			snprintf(tok, str - start + 1, start);
+			snprintf(tok, str - start + 1, "%s", start);
 			return str + 1;
 			break;
 
@@ -112,7 +112,7 @@
 				(*line_no)++;
 				str++;
 			} else {
-				snprintf(tok, str - start + 1, start);
+				snprintf(tok, str - start + 1, "%s", start);
 			}
 
 			return str;
@@ -126,10 +126,10 @@
 			 * a token on their own.
 			 */
 			if (start == NULL) {
-				snprintf(tok, 2, str);
+				snprintf(tok, 2, "%s", str);
 				str++;
 			} else {
-				snprintf(tok, str - start + 1, start);
+				snprintf(tok, str - start + 1, "%s", start);
 			}
 
 			return str;
@@ -150,10 +150,10 @@
 					else
 						str++;
 				}
-				snprintf(tok, str - start + 1, start);
+				snprintf(tok, str - start + 1, "%s", start);
 				str++;
 			} else {
-				snprintf(tok, str - start + 1, start);
+				snprintf(tok, str - start + 1, "%s", start);
 			}
 
 			return str;
@@ -210,7 +210,7 @@
 	if (start == NULL)
 		return NULL;
 
-	offset += sprintf(buf, tok);
+	offset += sprintf(buf, "%s", tok);
 
 	start = get_token(start, end, tok, line_no);
 	while ((start != NULL) && (tok[0] != '\n')) {
--- a/rtas_errd/v6ela.c
+++ b/rtas_errd/v6ela.c
@@ -359,7 +359,7 @@
 				offset += sprintf(buffer + offset, msg, 
 						  asctime(date)); 
 			else
-				offset += sprintf(buffer + offset, msg); 
+				offset += sprintf(buffer + offset, "%s", msg);
 		} 
 
 		if (menu_num == 0) {
--- a/rtas_errd/servicelog.c
+++ b/rtas_errd/servicelog.c
@@ -230,7 +230,7 @@
 		} else {
 			event->sl_entry->description = (char *)malloc(txtlen+1);
 			snprintf(event->sl_entry->description, txtlen,
-				 event->addl_text);
+				 "%s", event->addl_text);
 		}
 	}
 
--- a/diags/diag_encl.c
+++ b/diags/diag_encl.c
@@ -244,7 +244,7 @@
 
 	rc = servicelog_open(&slog, 0);
 	if (rc != 0) {
-		fprintf(stderr, servicelog_error(slog));
+		fprintf(stderr, "%s", servicelog_error(slog));
 		return 0;
 	}
 
@@ -253,7 +253,7 @@
 	servicelog_close(slog);
 
 	if (rc != 0) {
-		fprintf(stderr, servicelog_error(slog));
+		fprintf(stderr, "%s", servicelog_error(slog));
 		return 0;
 	}
 



--===============4107116188408576587==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
--===============4107116188408576587==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Linux-diag-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-diag-devel

--===============4107116188408576587==--