... | ... |
@@ -29,6 +29,8 @@ |
29 | 29 |
* 2003-01-29 transport-independent message zero-termination in |
30 | 30 |
* receive_msg (jiri) |
31 | 31 |
* 2003-02-07 undoed jiri's zero term. changes (they break tcp) (andrei) |
32 |
+ * 2003-02-10 moved zero-term in the calling functions (udp_receive & |
|
33 |
+ * tcp_read_req) |
|
32 | 34 |
*/ |
33 | 35 |
|
34 | 36 |
|
... | ... |
@@ -56,6 +58,10 @@ |
56 | 58 |
|
57 | 59 |
unsigned int msg_no=0; |
58 | 60 |
|
61 |
+ |
|
62 |
+/* WARNING: buf must be 0 terminated (buf[len]=0) or some things might |
|
63 |
+ * break (e.g.: modules/textops) |
|
64 |
+ */ |
|
59 | 65 |
int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) |
60 | 66 |
{ |
61 | 67 |
struct sip_msg* msg; |
... | ... |
@@ -92,9 +98,6 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info) |
92 | 98 |
goto error01; |
93 | 99 |
} |
94 | 100 |
memcpy(msg->orig, buf, len); |
95 |
- /* WARNING: zero term removed! */ |
|
96 |
- /* msg->orig[len]=0; */ /* null terminate it,good for using str* functions |
|
97 |
- on it*/ |
|
98 | 101 |
#endif |
99 | 102 |
|
100 | 103 |
if (parse_msg(buf,len, msg)!=0){ |
... | ... |
@@ -24,6 +24,12 @@ |
24 | 24 |
* along with this program; if not, write to the Free Software |
25 | 25 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
26 | 26 |
*/ |
27 |
+/* |
|
28 |
+ * History: |
|
29 |
+ * -------- |
|
30 |
+ * 2002-12-?? created by andrei. |
|
31 |
+ * 2003-02-10 zero term before calling receive_msg & undo afterwards (andrei) |
|
32 |
+ */ |
|
27 | 33 |
|
28 | 34 |
#ifdef USE_TCP |
29 | 35 |
|
... | ... |
@@ -351,6 +357,7 @@ int tcp_read_req(struct tcp_connection* con) |
351 | 357 |
long size; |
352 | 358 |
struct tcp_req* req; |
353 | 359 |
int s; |
360 |
+ char c; |
|
354 | 361 |
|
355 | 362 |
resp=CONN_RELEASE; |
356 | 363 |
s=con->fd; |
... | ... |
@@ -409,10 +416,16 @@ again: |
409 | 416 |
req->start, (int)(req->parsed-req->start)); |
410 | 417 |
bind_address=sendipv4; /*&tcp_info[con->sock_idx];*/ |
411 | 418 |
con->rcv.proto_reserved1=con->id; /* copy the id */ |
419 |
+ c=*req->parsed; /* ugly hack: zero term the msg & save the |
|
420 |
+ previous char, req->parsed should be ok |
|
421 |
+ because we always alloc BUF_SIZE+1 */ |
|
422 |
+ *req->parsed=0; |
|
412 | 423 |
if (receive_msg(req->start, req->parsed-req->start, &con->rcv)<0){ |
424 |
+ *req->parsed=c; |
|
413 | 425 |
resp=CONN_ERROR; |
414 | 426 |
goto end_req; |
415 | 427 |
} |
428 |
+ *req->parsed=c; |
|
416 | 429 |
|
417 | 430 |
/* prepare for next request */ |
418 | 431 |
size=req->pos-req->parsed; |
... | ... |
@@ -27,6 +27,7 @@ |
27 | 27 |
* History |
28 | 28 |
* -------- |
29 | 29 |
* 2003-01-28 packet zero-termination moved to receive_msg (jiri) |
30 |
+ * 2003-02-10 undoed the above changes (andrei) |
|
30 | 31 |
*/ |
31 | 32 |
|
32 | 33 |
|
... | ... |
@@ -317,8 +318,8 @@ int udp_rcv_loop() |
317 | 318 |
continue; /* goto skip;*/ |
318 | 319 |
else goto error; |
319 | 320 |
} |
320 |
- /*debugging, make print* msg work */ |
|
321 |
- /* buf[len+1]=0; */ /* zero-termination moved to receive_msg */ |
|
321 |
+ /* we must 0-term the messages, receive_msg expects it */ |
|
322 |
+ buf[len+1]=0; /* no need to save the previous char */ |
|
322 | 323 |
|
323 | 324 |
#ifndef NO_ZERO_CHECKS |
324 | 325 |
if (len==0) { |