logo       

Bug (and fix!): Wily crashes if B2 target is very big: msg#00022

editors.wily

Subject: Bug (and fix!): Wily crashes if B2 target is very big

The subject line makes the problem clear -- I'm using a 280,000-character
selection for my "too big" B2 target.

Fix follows (this is against my hacked 0.13.36, but it looks like it should
apply fine against 0.13.41).

Index: event.c
===================================================================
RCS file: /home/trost/cvsroot/wily/wily/event.c,v
retrieving revision 1.2
diff -u -u -r1.2 event.c
--- event.c 7 Nov 1997 21:25:59 -0000 1.2
+++ event.c 29 May 2004 02:42:46 -0000
@@ -63,7 +63,7 @@
static void key_del(Key *k);
static Key* key_new(ulong key, int fd, Keytype t);
static Key* key_findcmd(char*cmd);
-static void oneword(char*s, char*l);
+static void oneword(char* s, char* l, int s_length);
static void output(Key*k, int n, char*s);
static void ex_accept(int n, char*s);

@@ -106,7 +106,7 @@
if(k->v) {
k->first = true;
} else {
- oneword(k->cmd, cmd);
+ oneword(k->cmd, cmd, sizeof(k->cmd));
olabel(k->olabel, label);
addrunning(k->cmd);
}
@@ -225,12 +225,11 @@

/* Put a one-word version of long command 'l' into 's' */
static void
-oneword(char*s, char*l){
- strcpy(s,l);
-
- /* break at first whitespace */
- if( (s = strpbrk(s, whitespace)) )
- *s='\0';
+oneword(char*s, char*l, int s_length){
+ char *blank = strpbrk(l, whitespace);
+ if (blank && blank - l < s_length)
+ s_length = blank - l;
+ strlcpy(s,l, s_length);
}

/* Copy the 'n' bytes of data in 's' to the window or output directory




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise