summaryrefslogtreecommitdiff
path: root/debian/patches/08_add_newlines_between_serverdescriptors.dpatch
blob: aa4c662645d96ede01c93e328ddc91c822c672df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#! /bin/sh -e
## 07_log_to_file_by_default.dpatch by  <weasel@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

if [ $# -lt 1 ]; then
    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"

case "$1" in
    -patch) patch -p1 ${patch_opts} < $0;;
    -unpatch) patch -R -p1 ${patch_opts} < $0;;
    *)
        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
        exit 1;;
esac

exit 0

@DPATCH@
diff -u -d -r1.246 -r1.247
--- tor-0.1.1.9/src/or/dirserv.c	6 Oct 2005 04:33:40 -0000	1.246
+++ /tmp/dpep.YwfNhI/tor-0.1.1.9/src/or/dirserv.c	8 Oct 2005 06:02:41 -0000	1.247
@@ -731,6 +731,7 @@
 dirserv_dump_directory_to_string(char **dir_out,
                                  crypto_pk_env_t *private_key)
 {
+  char *cp;
   char *router_status;
   char *identity_pkey; /* Identity key, DER64-encoded. */
   char *recommended_versions;
@@ -765,7 +766,7 @@
   buf_len = 2048+strlen(recommended_versions)+
     strlen(router_status);
   SMARTLIST_FOREACH(descriptor_list, routerinfo_t *, ri,
-                    buf_len += ri->signed_descriptor_len);
+                    buf_len += ri->signed_descriptor_len+1);
   buf = tor_malloc(buf_len);
   /* We'll be comparing against buf_len throughout the rest of the
      function, though strictly speaking we shouldn't be able to exceed
@@ -785,9 +786,17 @@
   tor_free(router_status);
   tor_free(identity_pkey);
 
+  cp = buf + strlen(buf);
   SMARTLIST_FOREACH(descriptor_list, routerinfo_t *, ri,
-    if (strlcat(buf, ri->signed_descriptor, buf_len) >= buf_len)
-      goto truncated);
+    {
+      if (cp+ri->signed_descriptor_len+1 >= buf+buf_len)
+        goto truncated;
+      memcpy(cp, ri->signed_descriptor, ri->signed_descriptor_len);
+      cp += ri->signed_descriptor_len;
+      *cp++ = '\n'; /* add an extra newline in case somebody was depending on
+                     * it. */
+    });
+  *cp = '\0';
 
   /* These multiple strlcat calls are inefficient, but dwarfed by the RSA
      signature.