Skip to contentSkip to conversation

Patch to mheardd

PATCH Øyvind Hanssen 1 participant 1 message Nov 16, 2003

lore
Share & tools
lore
#0 lore raw

There was a problem with invalid packets: Especially, corrupted digipeater fields may lead to overwriting of memory far beyond the record in question. This may have security implications. In my case it led to denial of service because file-record locations were overwritten with garbage and the daemon attempted to write to these locations.

Now, with a sanity check of the digipeater field, the daemon now works correctly though the USCC card here generates many bad packets.

73 de LA7ECA, Oyvind

Signature · 1 line
Computer Science dept. University of Tromsø,  [email protected],  Cell: +47 9511 7457
mheardd.c renamed from mheardd.orig.c +10 -5
@@ -228,14 +228,14 @@
 				syslog(LOG_WARNING, "packet too short\n");
 			continue;
 		}
-
-		mheard = findentry((ax25_address *)(data + AXLEN), port);
-
+		
 		if (!ax25_validate(data + 0) || !ax25_validate(data + AXLEN)) {
 			if (logging)
 				syslog(LOG_WARNING, "invalid callsign on port %s\n", port);
 			continue;
 		}
+		
+		mheard = findentry((ax25_address *)(data + AXLEN), port);
 
 		memcpy(&mheard->entry.from_call, data + AXLEN, sizeof(ax25_address));
 		memcpy(&mheard->entry.to_call,   data + 0,     sizeof(ax25_address));
@@ -248,7 +248,7 @@
 		data += (AXLEN + AXLEN);
 		size -= (AXLEN + AXLEN);
 
-		while (!end) {
+		while (!end && mheard->entry.ndigis <= 7 && ax25_validate(data) ) {
 			memcpy(&mheard->entry.digis[mheard->entry.ndigis], data, sizeof(ax25_address));
 			mheard->entry.ndigis++;
 			
@@ -257,7 +257,12 @@
 			data += AXLEN;
 			size -= AXLEN;
 		}
-
+		if (!end) {
+		    if (logging)
+		        syslog(LOG_WARNING, "invalid digipeater field\n");
+                    continue; 
+		}
+		    
 		if (size == 0) {
 			if (logging)
 				syslog(LOG_WARNING, "packet too short\n");