aboutsummaryrefslogtreecommitdiff
path: root/src/tunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tunnel.c')
-rw-r--r--src/tunnel.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/tunnel.c b/src/tunnel.c
index 71495cc..299c254 100644
--- a/src/tunnel.c
+++ b/src/tunnel.c
@@ -2,7 +2,7 @@
2 tunnel.c 2 tunnel.c
3 3
4 This file is part of GNU Anubis. 4 This file is part of GNU Anubis.
5 Copyright (C) 2001-2014 The Anubis Team. 5 Copyright (C) 2001-2024 The Anubis Team.
6 6
7 GNU Anubis is free software; you can redistribute it and/or modify it 7 GNU Anubis is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the 8 under the terms of the GNU General Public License as published by the
@@ -21,10 +21,6 @@
21#include "headers.h" 21#include "headers.h"
22#include "extern.h" 22#include "extern.h"
23 23
24#define obstack_chunk_alloc malloc
25#define obstack_chunk_free free
26#include <obstack.h>
27
28static int transfer_command (MESSAGE); 24static int transfer_command (MESSAGE);
29static int process_command (MESSAGE, char *); 25static int process_command (MESSAGE, char *);
30static void process_data (MESSAGE); 26static void process_data (MESSAGE);
@@ -40,8 +36,6 @@ get_ehlo_domain (void)
40{ 36{
41 return smtp_ehlo_domain_name ? smtp_ehlo_domain_name : get_localname (); 37 return smtp_ehlo_domain_name ? smtp_ehlo_domain_name : get_localname ();
42} 38}
43
44
45 39
46 40
47/* Collect and send headers */ 41/* Collect and send headers */
@@ -210,14 +204,13 @@ collect_body (MESSAGE msg)
210 int nread; 204 int nread;
211 char *buf = NULL; 205 char *buf = NULL;
212 size_t size = 0; 206 size_t size = 0;
213 struct obstack stk; 207 struct stringbuf sb = STRINGBUF_INITIALIZER;
214 int state = 0; 208 int state = 0;
215 int len; 209 int len;
216 const char *boundary = message_get_boundary (msg); 210 const char *boundary = message_get_boundary (msg);
217 211
218 if (boundary) 212 if (boundary)
219 len = strlen (boundary); 213 len = strlen (boundary);
220 obstack_init (&stk);
221 while (state != ST_DONE 214 while (state != ST_DONE
222 && (nread = recvline (SERVER, remote_client, &buf, &size))) 215 && (nread = recvline (SERVER, remote_client, &buf, &size)))
223 { 216 {
@@ -247,22 +240,20 @@ collect_body (MESSAGE msg)
247 state = ST_DONE; 240 state = ST_DONE;
248 else 241 else
249 { 242 {
250 obstack_grow (&stk, buf, strlen (buf)); 243 stringbuf_add_string (&sb, buf);
251 obstack_1grow (&stk, '\n'); 244 stringbuf_add_char (&sb, '\n');
252 } 245 }
253 } 246 }
254 } 247 }
255 else 248 else
256 { 249 {
257 obstack_grow (&stk, buf, strlen (buf)); 250 stringbuf_add_string (&sb, buf);
258 obstack_1grow (&stk, '\n'); 251 stringbuf_add_char (&sb, '\n');
259 } 252 }
260 } 253 }
261 free (buf); 254 free (buf);
262 obstack_1grow (&stk, 0);
263 /* FIXME: Use message_proc_body to avoid spurious reallocations */ 255 /* FIXME: Use message_proc_body to avoid spurious reallocations */
264 message_replace_body (msg, xstrdup (obstack_finish (&stk))); 256 message_replace_body (msg, stringbuf_finish (&sb));
265 obstack_free (&stk, NULL);
266} 257}
267 258
268void 259void

Return to:

Send suggestions and report system problems to the System administrator.