Browse code

core: check if the tcp clone rcv buffer is set when applying changes

Daniel-Constantin Mierla authored on 26/11/2020 12:54:42
Showing 3 changed files
... ...
@@ -3252,7 +3252,12 @@ int sip_msg_update_buffer(sip_msg_t *msg, str *obuf)
3252 3252
 		LM_ERR("invalid buffer parameter\n");
3253 3253
 		return -1;
3254 3254
 	}
3255
-
3255
+#ifdef USE_TCP
3256
+	if(tcp_get_clone_rcvbuf()==0) {
3257
+		LM_ERR("tcp clone received buffer not enabled\n");
3258
+		return -1;
3259
+	}
3260
+#endif
3256 3261
 	if(obuf->len >= BUF_SIZE) {
3257 3262
 		LM_ERR("new buffer is too large (%d)\n", obuf->len);
3258 3263
 		return -1;
... ...
@@ -157,6 +157,7 @@ void tcp_options_get(struct cfg_group_tcp* t);
157 157
 
158 158
 #ifdef USE_TCP
159 159
 int tcp_set_clone_rcvbuf(int v);
160
+int tcp_get_clone_rcvbuf(void);
160 161
 #endif /* USE_TCP */
161 162
 
162 163
 #endif /* tcp_options_h */
... ...
@@ -109,6 +109,11 @@ int tcp_set_clone_rcvbuf(int v)
109 109
 	return r;
110 110
 }
111 111
 
112
+int tcp_get_clone_rcvbuf(void)
113
+{
114
+	return tcp_clone_rcvbuf;
115
+}
116
+
112 117
 #ifdef READ_HTTP11
113 118
 int tcp_http11_continue(struct tcp_connection *c)
114 119
 {