Browse code

msg_qa now drops suspicious incomign messages on the floor and it aborts only of messages sent out are suspicious

Jiri Kuthan authored on 08/09/2002 22:33:48
Showing 1 changed files
... ...
@@ -234,6 +234,13 @@ int udp_rcv_loop()
234 234
 			len--;
235 235
 		}
236 236
 #endif
237
+#ifdef DBG_MSG_QA
238
+		if (!dbg_msg_qa(buf, len)) {
239
+			LOG(L_WARN, "WARNING: an incoming message didn't pass test, drop it: %.*s\n",
240
+				len, buf );
241
+			continue;
242
+		}
243
+#endif
237 244
 		
238 245
 		/* receive_msg must free buf too!*/
239 246
 		receive_msg(buf, len, from);
... ...
@@ -259,7 +266,7 @@ error:
259 259
    in generated messages; this debugging option aborts if
260 260
    any such message is sighted
261 261
 */
262
-void dbg_msg_qa(char *buf, int len)
262
+int dbg_msg_qa(char *buf, int len)
263 263
 {
264 264
 #define _DBG_WS_LEN 3
265 265
 #define _DBG_WS "   "
... ...
@@ -273,7 +280,7 @@ void dbg_msg_qa(char *buf, int len)
273 273
 	/* is there a zero character inthere ? */	
274 274
 	if (memchr(buf, 0, len)) {
275 275
 		LOG(L_CRIT, "BUG: message being sent with 0 in it\n");
276
-		abort();
276
+		return 0;
277 277
 	}
278 278
 
279 279
 	my_len=len;
... ...
@@ -288,7 +295,7 @@ void dbg_msg_qa(char *buf, int len)
288 288
 							if (space_cnt==4) {
289 289
 								LOG(L_CRIT, "BUG(propably): DBG_MSG_QA: "
290 290
 									"too many spaces\n");
291
-								abort();
291
+								return 0;
292 292
 							}
293 293
 						} else space_cnt=0;
294 294
 						state=QA_SPACE; 
... ...
@@ -314,7 +321,7 @@ void dbg_msg_qa(char *buf, int len)
314 314
 
315 315
 
316 316
 qa_passed:
317
-	return;
317
+	return 1;
318 318
 }
319 319
 
320 320
 #endif
... ...
@@ -328,7 +335,10 @@ int udp_send(struct socket_info *source, char *buf, unsigned len,
328 328
 
329 329
 #ifdef DBG_MSG_QA
330 330
 	/* aborts on error, does nothing otherwise */
331
-	dbg_msg_qa( buf, len );
331
+	if (!dbg_msg_qa( buf, len )) {
332
+		LOG(L_ERR, "ERROR: udp_send: dbg_msg_qa failed\n");
333
+		abort();
334
+	}
332 335
 #endif
333 336
 
334 337