aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor Lane Smith <cls@lubutu.com>2011-05-16 23:35:14 +0100
committerConnor Lane Smith <cls@lubutu.com>2011-05-16 23:35:14 +0100
commit3a60b19514705f7f61908fd727d2e69565ee1947 (patch)
tree5346988068977145a924708dc40ef221d7cc7a9a
parentdd2f298252fc21ff7d3b14296068443cb39c38d9 (diff)
fix possible overflow
-rw-r--r--dmenu.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/dmenu.c b/dmenu.c
index a32131c..c4b7908 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -31,7 +31,7 @@ static void grabkeyboard(void);
31static void insert(const char *str, ssize_t n); 31static void insert(const char *str, ssize_t n);
32static void keypress(XKeyEvent *ev); 32static void keypress(XKeyEvent *ev);
33static void match(Bool sub); 33static void match(Bool sub);
34static size_t nextrune(int incr); 34static size_t nextrune(int inc);
35static void paste(void); 35static void paste(void);
36static void readstdin(void); 36static void readstdin(void);
37static void run(void); 37static void run(void);
@@ -426,10 +426,10 @@ match(Bool sub) {
426} 426}
427 427
428size_t 428size_t
429nextrune(int incr) { 429nextrune(int inc) {
430 size_t n, len = strlen(text); 430 ssize_t n;
431 431
432 for(n = cursor + incr; n < len && (text[n] & 0xc0) == 0x80; n += incr); 432 for(n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc);
433 return n; 433 return n;
434} 434}
435 435