From 8dcb9f317a74c30bf33c881b27307bba981025a0 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 24 Oct 2016 18:57:50 -0400 Subject: [PATCH] Fixed a buffer overflow for long paths in the status bar --- xedit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xedit.c b/xedit.c index 0dda2ed..0e4f282 100644 --- a/xedit.c +++ b/xedit.c @@ -361,6 +361,13 @@ static void draw_status(XftColor* fg, unsigned ncols) { (status++)->rune = (Buffer.modified ? '*' : ' '); (status++)->rune = ' '; char* path = Buffer.path; + size_t len = strlen(path); + if (len > ncols-4) { + (status++)->rune = '.'; + (status++)->rune = '.'; + (status++)->rune = '.'; + path += (len - ncols) + 6; + } while(*path) (status++)->rune = *path++; draw_runes(0, 0, fg, NULL, glyphs, status - glyphs); -- 2.49.0