summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Nimmagadda <sunil@nimmagadda.net>2014-08-27 10:35:33 +0500
committerSunil Nimmagadda <sunil@nimmagadda.net>2014-08-27 10:35:33 +0500
commitbf0ea9ea9efb05be1e6cbb23574b001fd0372b79 (patch)
treeb10a6ecb37cb79a724bd3023a5c30642719f8475
parent3d1c9e91db3ff5929436ef93e0e5a5ed45687e79 (diff)
Bounds check array index. Fixes a crash when len == 1.
-rw-r--r--session.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/session.c b/session.c
index 025105e..da90c78 100644
--- a/session.c
+++ b/session.c
@@ -708,7 +708,7 @@ session_write(struct session *s, const char *data, size_t len)
if (data[len - 1] == '\n')
len -= 1;
- if (data[len - 1] == '\r')
+ if (len && data[len - 1] == '\r')
len -= 1;
/* byte stuff "." if at beginning of line */