Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Avoid buffer overflow on strncat usage
@ 2014-02-03 17:54 Dirk Müller
  2014-02-04  8:30 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Dirk Müller @ 2014-02-03 17:54 UTC (permalink / raw)
  To: kexec

strncat() does not want the total size but the maximum length.

Signed-off-by: Dirk Mueller <dmueller@suse.com>
---
 kexec/fs2dt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index 73c1fb9..65a8b66 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -649,8 +649,8 @@ static void putnode(void)
                        goto no_debug;
                }
                strncpy(filename, "/proc/device-tree/", MAXPATH);
-               strncat(filename, buff, MAXPATH);
-               strncat(filename, "/compatible", MAXPATH);
+               strncat(filename, buff, MAXPATH-strlen(filename)-1);
+               strncat(filename, "/compatible", MAXPATH-strlen(filename)-1);
                fd = open(filename, O_RDONLY);
                if (fd == -1) {
                        printf("Unable to find %s printing from
purgatory is diabled\n",
-- 
1.8.4.1

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

end of thread, other threads:[~2014-02-04 12:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-03 17:54 [PATCH] Avoid buffer overflow on strncat usage Dirk Müller
2014-02-04  8:30 ` Simon Horman
2014-02-04 12:03   ` Dirk Müller
2014-02-04 12:37     ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox