aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Edgar2013-10-05 11:45:44 +0200
committerRoberto E. Vargas Caballero2013-10-07 21:03:51 +0200
commit18c014f8cce8bb48447381f22f1b5cfb5e4b288d (patch)
treee633915fa74306f7abcd4a1c769ce368fbc8355e
parent754cf607eaee6426f10bf89125fdad076a65f294 (diff)
downloadaur-18c014f8cce8bb48447381f22f1b5cfb5e4b288d.tar.gz
Avoid buffer overrun in kpress() and remove limit on shortcut strings.
-rw-r--r--st.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/st.c b/st.c
index 331509fdb683..16bf68bf0480 100644
--- a/st.c
+++ b/st.c
@@ -264,7 +264,7 @@ typedef struct {
typedef struct {
KeySym k;
uint mask;
- char s[ESC_BUF_SIZ];
+ char *s;
/* three valued logic variables: 0 indifferent, 1 on, -1 off */
signed char appkey; /* application keypad */
signed char appcursor; /* application cursor */
@@ -3585,26 +3585,27 @@ kpress(XEvent *ev) {
/* 2. custom keys from config.h */
if((customkey = kmap(ksym, e->state))) {
len = strlen(customkey);
- memcpy(buf, customkey, len);
- /* 3. composed string from input method */
- } else {
- if(len == 0)
- return;
+ ttywrite(customkey, len);
+ if(IS_SET(MODE_ECHO))
+ techo(customkey, len);
+ return;
+ }
- if(len == 1 && e->state & Mod1Mask) {
- if(IS_SET(MODE_8BIT)) {
- if(*buf < 0177) {
- c = *buf | 0x80;
- len = utf8encode(&c, buf);
- }
- } else {
- buf[1] = buf[0];
- buf[0] = '\033';
- len = 2;
+ /* 3. composed string from input method */
+ if(len == 0)
+ return;
+ if(len == 1 && e->state & Mod1Mask) {
+ if(IS_SET(MODE_8BIT)) {
+ if(*buf < 0177) {
+ c = *buf | 0x80;
+ len = utf8encode(&c, buf);
}
+ } else {
+ buf[1] = buf[0];
+ buf[0] = '\033';
+ len = 2;
}
}
-
ttywrite(buf, len);
if(IS_SET(MODE_ECHO))
techo(buf, len);