diff options
author | Roger Dingledine <arma@torproject.org> | 2004-11-29 06:43:21 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-11-29 06:43:21 +0000 |
commit | 185f0474509fef19052562b6264fa3ca25bb1bc8 (patch) | |
tree | 264a497492206ba443a00f6932579e8141a7cc87 | |
parent | 9811f683103dd3e6aee8b8ffc4cc69ca36059f47 (diff) | |
download | tor-185f0474509fef19052562b6264fa3ca25bb1bc8.tar.gz tor-185f0474509fef19052562b6264fa3ca25bb1bc8.zip |
prevent integer underflow
(not currently exploitable, ilja and i think)
svn:r3010
-rw-r--r-- | src/common/log.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/common/log.c b/src/common/log.c index f227ebc399..4e4bc1862b 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -122,6 +122,10 @@ static INLINE char *format_msg(char *buf, size_t buf_len, size_t n; int r; char *end_of_prefix; + if (buf_len < 2) { /* prevent integer underflow */ + tor_assert(0); + exit(1); + } buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */ n = _log_prefix(buf, buf_len, severity); |