diff options
-rw-r--r-- | src/or/dirserv.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 45de98265d..12893163dc 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1563,14 +1563,16 @@ generate_v2_networkstatus(void) outp += strlen(outp); if (ri->platform && !strcmpstart(ri->platform, "Tor ")) { const char *eos = find_whitespace(ri->platform+4); - char *platform = tor_strndup(ri->platform+4, eos-(ri->platform+4)); - if (tor_snprintf(outp, endp-outp, - "opt v %s\n", platform)<0) { - log_warn(LD_BUG, "Unable to print router version."); - goto done; + if (eos) { + char *platform = tor_strndup(ri->platform, eos-(ri->platform)); + if (tor_snprintf(outp, endp-outp, + "opt v %s\n", platform)<0) { + log_warn(LD_BUG, "Unable to print router version."); + goto done; + } + tor_free(platform); + outp += strlen(outp); } - tor_free(platform); - outp += strlen(outp); } } }); |