[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/maint-0.2.2] Use strlcpy when copying node IDs into measured_bw_line_t



commit bc91cb6e459042e11be11e50050ac086fdcb33dd
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Jul 1 12:14:44 2011 -0400

    Use strlcpy when copying node IDs into measured_bw_line_t
    
    We were using strncpy before, which isn't our style for stuff like
    this.
    
    This isn't a bug, though: before calling strncpy, we were checking
    that strlen(src) was indeed == HEX_DIGEST_LEN, which is less than
    sizeof(dst), so there was no way we could fail to NUL-terminate.
    Still, strncpy(a,b,sizeof(a)) is an idiom that we ought to squash
    everyplace.
    
    Fixes CID #427.
---
 src/or/dirserv.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index d114d86..7df9a2f 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -2415,7 +2415,7 @@ measured_bw_line_parse(measured_bw_line_t *out, const char *orig_line)
         tor_free(line);
         return -1;
       }
-      strncpy(out->node_hex, cp, sizeof(out->node_hex));
+      strlcpy(out->node_hex, cp, sizeof(out->node_hex));
       got_node_id=1;
     }
   } while ((cp = tor_strtok_r(NULL, " \t", &strtok_state)));



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits