vmps request: long attribute VQP-Ethernet-Frame again

Hermann Lauer Hermann.Lauer at iwr.uni-heidelberg.de
Tue Jan 5 12:30:15 CET 2010


On Mon, Jan 04, 2010 at 03:07:13PM +0100, Hermann Lauer wrote:
> Unfortunately the cutting solution which was included after the discussion above was no
> completely correct, because the vqp_recv routine has to skip the complete ethernet packet
> in checking as otherwise the rest would be interpeted as garbage, which makes
> the server rejecting the packet with a "Packet contains invalid attribute"
> message. The appended patch tries to fix this, but now memory errors occurs:

shorted lenght must be used while copying, correct patch is attached.
-------------- next part --------------
fix len skipping

diff --git a/src/lib/vqp.c b/src/lib/vqp.c
--- a/src/lib/vqp.c
+++ b/src/lib/vqp.c
@@ -374,7 +374,7 @@
 				rad_free(&packet);
 				return NULL;
 			}
-			attrlen = ptr[5];
+			attrlen = (ptr[4] << 8) | ptr[5];
 			ptr += 6 + attrlen;
 			length -= (6 + attrlen);
 		}
@@ -507,8 +507,8 @@
 		case PW_TYPE_OCTETS:
 		case PW_TYPE_STRING:
 			vp->length = (length > MAX_VMPS_LEN) ? MAX_VMPS_LEN : length;
-			memcpy(vp->vp_octets, ptr, length);
-			vp->vp_octets[length] = '\0';
+			memcpy(vp->vp_octets, ptr, vp->length);
+			vp->vp_octets[vp->length] = '\0';
 			break;
 		}
 		ptr += length;


More information about the Freeradius-Devel mailing list