[tor-commits] [tor/master] Check the return value of memchr().

nickm at torproject.org nickm at torproject.org
Tue May 14 16:26:33 UTC 2013


commit 88a780d8990622bfc0faa3b5299d0c21012f2c41
Author: Arlo Breault <arlolra at gmail.com>
Date:   Mon May 13 12:32:01 2013 -0700

    Check the return value of memchr().
    
    For quality-of-implementation in munge_extrainfo_into_routerinfo().
    See #8791
---
 src/or/control.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/or/control.c b/src/or/control.c
index 4878268..75f7af9 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1572,7 +1572,8 @@ munge_extrainfo_into_routerinfo(const char *ri_body,
     if (!(cp = tor_memstr(ei_body, ei_len, kwd)))
       continue;
     ++cp;
-    eol = memchr(cp, '\n', ei_len - (cp-ei_body));
+    if (!(eol = memchr(cp, '\n', ei_len - (cp-ei_body))))
+      continue;
     memcpy(outp, cp, eol-cp+1);
     outp += eol-cp+1;
   }





More information about the tor-commits mailing list