08_add_newlines_between_serverdescriptors.dpatch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #! /bin/sh -e
  2. ## 07_log_to_file_by_default.dpatch by <weasel@debian.org>
  3. ##
  4. ## All lines beginning with `## DP:' are a description of the patch.
  5. ## DP: No description.
  6. if [ $# -lt 1 ]; then
  7. echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
  8. exit 1
  9. fi
  10. [ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
  11. patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
  12. case "$1" in
  13. -patch) patch -p1 ${patch_opts} < $0;;
  14. -unpatch) patch -R -p1 ${patch_opts} < $0;;
  15. *)
  16. echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
  17. exit 1;;
  18. esac
  19. exit 0
  20. @DPATCH@
  21. diff -u -d -r1.246 -r1.247
  22. --- tor-0.1.1.9/src/or/dirserv.c 6 Oct 2005 04:33:40 -0000 1.246
  23. +++ /tmp/dpep.YwfNhI/tor-0.1.1.9/src/or/dirserv.c 8 Oct 2005 06:02:41 -0000 1.247
  24. @@ -731,6 +731,7 @@
  25. dirserv_dump_directory_to_string(char **dir_out,
  26. crypto_pk_env_t *private_key)
  27. {
  28. + char *cp;
  29. char *router_status;
  30. char *identity_pkey; /* Identity key, DER64-encoded. */
  31. char *recommended_versions;
  32. @@ -765,7 +766,7 @@
  33. buf_len = 2048+strlen(recommended_versions)+
  34. strlen(router_status);
  35. SMARTLIST_FOREACH(descriptor_list, routerinfo_t *, ri,
  36. - buf_len += ri->signed_descriptor_len);
  37. + buf_len += ri->signed_descriptor_len+1);
  38. buf = tor_malloc(buf_len);
  39. /* We'll be comparing against buf_len throughout the rest of the
  40. function, though strictly speaking we shouldn't be able to exceed
  41. @@ -785,9 +786,17 @@
  42. tor_free(router_status);
  43. tor_free(identity_pkey);
  44. + cp = buf + strlen(buf);
  45. SMARTLIST_FOREACH(descriptor_list, routerinfo_t *, ri,
  46. - if (strlcat(buf, ri->signed_descriptor, buf_len) >= buf_len)
  47. - goto truncated);
  48. + {
  49. + if (cp+ri->signed_descriptor_len+1 >= buf+buf_len)
  50. + goto truncated;
  51. + memcpy(cp, ri->signed_descriptor, ri->signed_descriptor_len);
  52. + cp += ri->signed_descriptor_len;
  53. + *cp++ = '\n'; /* add an extra newline in case somebody was depending on
  54. + * it. */
  55. + });
  56. + *cp = '\0';
  57. /* These multiple strlcat calls are inefficient, but dwarfed by the RSA
  58. signature.