]> git.mdlowis.com Git - projs/tide.git/commitdiff
Fixed a buffer overflow for long paths in the status bar
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 24 Oct 2016 22:57:50 +0000 (18:57 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 24 Oct 2016 22:57:50 +0000 (18:57 -0400)
xedit.c

diff --git a/xedit.c b/xedit.c
index 0dda2edd1ade0b1c0d7f031b3d2b3f4382495046..0e4f28283b5fa24e8b3815e2b5fc4ca558015df1 100644 (file)
--- 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);