[hackers] [dmenu] fix possible overflow || Connor Lane Smith

From: <hg_AT_suckless.org>
Date: Tue, 17 May 2011 00:35:29 +0200 (CEST)

changeset: 409:b3c38b8db40e
tag: tip
user: Connor Lane Smith <cls_AT_lubutu.com>
date: Mon May 16 23:35:14 2011 +0100
files: dmenu.c
description:
fix possible overflow

diff -r ea56fcb99615 -r b3c38b8db40e dmenu.c
--- a/dmenu.c Mon May 16 12:59:31 2011 +0100
+++ b/dmenu.c Mon May 16 23:35:14 2011 +0100
@@ -31,7 +31,7 @@
 static void insert(const char *str, ssize_t n);
 static void keypress(XKeyEvent *ev);
 static void match(Bool sub);
-static size_t nextrune(int incr);
+static size_t nextrune(int inc);
 static void paste(void);
 static void readstdin(void);
 static void run(void);
@@ -426,10 +426,10 @@
 }
 
 size_t
-nextrune(int incr) {
- size_t n, len = strlen(text);
+nextrune(int inc) {
+ ssize_t n;
 
- for(n = cursor + incr; n < len && (text[n] & 0xc0) == 0x80; n += incr);
+ for(n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc);
         return n;
 }
 
Received on Tue May 17 2011 - 00:35:29 CEST

This archive was generated by hypermail 2.2.0 : Tue May 17 2011 - 00:36:04 CEST