Committed by
Gerrit Code Review
Adding some extra checks against bufer overflow
Change-Id: I08b53823792de363c7da22cda1db198b95242ba4
Showing
1 changed file
with
4 additions
and
1 deletions
| ... | @@ -24,7 +24,8 @@ import java.util.ArrayList; | ... | @@ -24,7 +24,8 @@ import java.util.ArrayList; |
| 24 | import java.util.List; | 24 | import java.util.List; |
| 25 | import java.util.ListIterator; | 25 | import java.util.ListIterator; |
| 26 | 26 | ||
| 27 | -import static org.onlab.packet.PacketUtils.*; | 27 | +import static com.google.common.base.Preconditions.checkArgument; |
| 28 | +import static org.onlab.packet.PacketUtils.checkInput; | ||
| 28 | 29 | ||
| 29 | /** | 30 | /** |
| 30 | * | 31 | * |
| ... | @@ -423,6 +424,8 @@ public class DHCP extends BasePacket { | ... | @@ -423,6 +424,8 @@ public class DHCP extends BasePacket { |
| 423 | bb.putInt(this.yourIPAddress); | 424 | bb.putInt(this.yourIPAddress); |
| 424 | bb.putInt(this.serverIPAddress); | 425 | bb.putInt(this.serverIPAddress); |
| 425 | bb.putInt(this.gatewayIPAddress); | 426 | bb.putInt(this.gatewayIPAddress); |
| 427 | + checkArgument(this.clientHardwareAddress.length <= 16, | ||
| 428 | + "Hardware address is too long (%s bytes)", this.clientHardwareAddress.length); | ||
| 426 | bb.put(this.clientHardwareAddress); | 429 | bb.put(this.clientHardwareAddress); |
| 427 | if (this.clientHardwareAddress.length < 16) { | 430 | if (this.clientHardwareAddress.length < 16) { |
| 428 | for (int i = 0; i < 16 - this.clientHardwareAddress.length; ++i) { | 431 | for (int i = 0; i < 16 - this.clientHardwareAddress.length; ++i) { | ... | ... |
-
Please register or login to post a comment