Skip to contentSkip to conversation

libiptc: fix fortify errors in debug code

PATCH In review Mike Frysinger 2 participants 2 messages Aug 20, 2015 – Aug 26, 2015 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libiptc: fix fortify errors in debug code

When using open(O_CREAT), you must supply the mode bits, otherwise the func will pull random garbage off the stack.

---
 libiptc/libiptc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libiptc/libiptc.c +3 -3
index f0f7815..9c07bb4 100644
@@ -1357,7 +1357,7 @@ retry:
 #ifdef IPTC_DEBUG2
 	{
 		int fd = open("/tmp/libiptc-so_get_entries.blob",
-				O_CREAT|O_WRONLY);
+				O_CREAT|O_WRONLY, 0644);
 		if (fd >= 0) {
 			write(fd, h->entries, tmp);
 			close(fd);
@@ -2588,7 +2588,7 @@ TC_COMMIT(struct xtc_handle *handle)
 #ifdef IPTC_DEBUG2
 	{
 		int fd = open("/tmp/libiptc-so_set_replace.blob",
-				O_CREAT|O_WRONLY);
+				O_CREAT|O_WRONLY, 0644);
 		if (fd >= 0) {
 			write(fd, repl, sizeof(*repl) + repl->size);
 			close(fd);
@@ -2664,7 +2664,7 @@ TC_COMMIT(struct xtc_handle *handle)
 #ifdef IPTC_DEBUG2
 	{
 		int fd = open("/tmp/libiptc-so_set_add_counters.blob",
-				O_CREAT|O_WRONLY);
+				O_CREAT|O_WRONLY, 0644);
 		if (fd >= 0) {
 			write(fd, newcounters, counterlen);
 			close(fd);
Signature · 1 line
2.4.4
#1 lore raw
Quoted 2 lines · Mike Frysinger

When using open(O_CREAT), you must supply the mode bits, otherwise the func will pull random garbage off the stack.

Also applied, thanks.