HADOOP-9806 PortmapInterface should check if the procedure is out-of-range. Contributed by Brandon Li

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1509347 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brandon Li 2013-08-01 17:48:01 +00:00
parent 381a4c4213
commit 60be5fb9ed
3 changed files with 15 additions and 16 deletions

View File

@ -269,6 +269,9 @@ Trunk (Unreleased)
HADOOP-9433 TestLocalFileSystem#testHasFileDescriptor leaks file handle HADOOP-9433 TestLocalFileSystem#testHasFileDescriptor leaks file handle
(Chris Nauroth via sanjay) (Chris Nauroth via sanjay)
HADOOP-9806 PortmapInterface should check if the procedure is out-of-range
(brandonli)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-7761. Improve the performance of raw comparisons. (todd) HADOOP-7761. Improve the performance of raw comparisons. (todd)

View File

@ -45,6 +45,9 @@ public interface PortmapInterface {
} }
public static Procedure fromValue(int value) { public static Procedure fromValue(int value) {
if (value < 0 || value >= values().length) {
return null;
}
return values()[value]; return values()[value];
} }
} }

View File

@ -131,29 +131,22 @@ public class RpcProgramPortmap extends RpcProgram implements PortmapInterface {
@Override @Override
public XDR handleInternal(RpcCall rpcCall, XDR in, XDR out, public XDR handleInternal(RpcCall rpcCall, XDR in, XDR out,
InetAddress client, Channel channel) { InetAddress client, Channel channel) {
Procedure procedure = Procedure.fromValue(rpcCall.getProcedure()); final Procedure portmapProc = Procedure.fromValue(rpcCall.getProcedure());
int xid = rpcCall.getXid(); int xid = rpcCall.getXid();
switch (procedure) { if (portmapProc == Procedure.PMAPPROC_NULL) {
case PMAPPROC_NULL:
out = nullOp(xid, in, out); out = nullOp(xid, in, out);
break; } else if (portmapProc == Procedure.PMAPPROC_SET) {
case PMAPPROC_SET:
out = set(xid, in, out); out = set(xid, in, out);
break; } else if (portmapProc == Procedure.PMAPPROC_UNSET) {
case PMAPPROC_UNSET:
out = unset(xid, in, out); out = unset(xid, in, out);
break; } else if (portmapProc == Procedure.PMAPPROC_DUMP) {
case PMAPPROC_DUMP:
out = dump(xid, in, out); out = dump(xid, in, out);
break; } else if (portmapProc == Procedure.PMAPPROC_GETPORT) {
case PMAPPROC_GETPORT:
out = getport(xid, in, out); out = getport(xid, in, out);
break; } else if (portmapProc == Procedure.PMAPPROC_GETVERSADDR) {
case PMAPPROC_GETVERSADDR:
out = getport(xid, in, out); out = getport(xid, in, out);
break; } else {
default: LOG.info("PortmapHandler unknown rpc procedure=" + portmapProc);
LOG.info("PortmapHandler unknown rpc procedure=" + procedure);
RpcAcceptedReply.voidReply(out, xid, RpcAcceptedReply.voidReply(out, xid,
RpcAcceptedReply.AcceptState.PROC_UNAVAIL); RpcAcceptedReply.AcceptState.PROC_UNAVAIL);
} }