Skip to content

Instantly share code, notes, and snippets.

@postwait
Created February 24, 2014 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save postwait/9196621 to your computer and use it in GitHub Desktop.
Save postwait/9196621 to your computer and use it in GitHub Desktop.
diff --git a/src/modules/external.c b/src/modules/external.c
index 6996446..fa2c859 100644
--- a/src/modules/external.c
+++ b/src/modules/external.c
@@ -310,7 +310,9 @@ static int external_handler(eventer_t e, int mask,
}
while(data->cr->stderrlen_sofar < (int)data->cr->stderrlen) {
int stderrlen = (int)data->cr->stderrlen;
- if(stderrlen > data->cr->stderrlen_sofar) goto widowed; /* overflow */
+ if((stderrlen - data->cr->stderrlen_sofar) < 0 ||
+ (size_t)(stderrlen - data->cr->stderrlen_sofar) > data->cr->stderrlen)
+ goto widowed; /* overflow */
while((inlen =
read(e->fd,
data->cr->stderrbuff + data->cr->stderrlen_sofar,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment