Fix: resolve potential NPE in LispInfo request and reply

Change-Id: Iab01f0d2c947e918d5c131a7e416582f9fad9496
This commit is contained in:
Jian Li 2017-05-23 14:24:11 +09:00
parent ab7a1f6875
commit 03398d53cb
2 changed files with 31 additions and 24 deletions

View File

@ -63,7 +63,7 @@ public final class DefaultLispInfoReply extends DefaultLispInfo implements LispI
* @param eidPrefix EID prefix
* @param natLcafAddress NAT LCAF address
*/
protected DefaultLispInfoReply(boolean infoReply, long nonce, short keyId, short authDataLength,
DefaultLispInfoReply(boolean infoReply, long nonce, short keyId, short authDataLength,
byte[] authData, int ttl, byte maskLength,
LispAfiAddress eidPrefix, LispNatLcafAddress natLcafAddress) {
super(infoReply, nonce, keyId, authDataLength, authData, ttl, maskLength, eidPrefix);
@ -249,16 +249,19 @@ public final class DefaultLispInfoReply extends DefaultLispInfo implements LispI
LispNatLcafAddress natLcafAddress = (LispNatLcafAddress)
new LcafAddressReader().readFrom(byteBuf);
return new DefaultInfoReplyBuilder()
.withIsInfoReply(lispInfo.isInfoReply())
.withNonce(lispInfo.getNonce())
.withKeyId(lispInfo.getKeyId())
.withAuthDataLength(lispInfo.getAuthDataLength())
.withAuthData(lispInfo.getAuthData())
.withTtl(lispInfo.getTtl())
.withMaskLength(lispInfo.getMaskLength())
.withEidPrefix(lispInfo.getPrefix())
.withNatLcafAddress(natLcafAddress).build();
if (lispInfo != null) {
return new DefaultInfoReplyBuilder()
.withIsInfoReply(lispInfo.isInfoReply())
.withNonce(lispInfo.getNonce())
.withKeyId(lispInfo.getKeyId())
.withAuthDataLength(lispInfo.getAuthDataLength())
.withAuthData(lispInfo.getAuthData())
.withTtl(lispInfo.getTtl())
.withMaskLength(lispInfo.getMaskLength())
.withEidPrefix(lispInfo.getPrefix())
.withNatLcafAddress(natLcafAddress).build();
}
return null;
}
}

View File

@ -60,10 +60,10 @@ public class DefaultLispInfoRequest extends DefaultLispInfo
* @param maskLength EID prefix mask length
* @param eidPrefix EID prefix
*/
protected DefaultLispInfoRequest(boolean infoReply, long nonce, short keyId,
short authDataLength, byte[] authData,
int ttl, byte maskLength,
LispAfiAddress eidPrefix) {
DefaultLispInfoRequest(boolean infoReply, long nonce, short keyId,
short authDataLength, byte[] authData,
int ttl, byte maskLength,
LispAfiAddress eidPrefix) {
super(infoReply, nonce, keyId, authDataLength, authData, ttl,
maskLength, eidPrefix);
@ -239,15 +239,19 @@ public class DefaultLispInfoRequest extends DefaultLispInfo
LispInfo lispInfo = deserialize(byteBuf);
return new DefaultInfoRequestBuilder()
.withIsInfoReply(lispInfo.isInfoReply())
.withNonce(lispInfo.getNonce())
.withKeyId(lispInfo.getKeyId())
.withAuthDataLength(lispInfo.getAuthDataLength())
.withAuthData(lispInfo.getAuthData())
.withTtl(lispInfo.getTtl())
.withMaskLength(lispInfo.getMaskLength())
.withEidPrefix(lispInfo.getPrefix()).build();
if (lispInfo != null) {
return new DefaultInfoRequestBuilder()
.withIsInfoReply(lispInfo.isInfoReply())
.withNonce(lispInfo.getNonce())
.withKeyId(lispInfo.getKeyId())
.withAuthDataLength(lispInfo.getAuthDataLength())
.withAuthData(lispInfo.getAuthData())
.withTtl(lispInfo.getTtl())
.withMaskLength(lispInfo.getMaskLength())
.withEidPrefix(lispInfo.getPrefix()).build();
}
return null;
}
}