Program: 37454
Project: 37454
Buggy source:
/** 
 * invoked by upper functions.
 * @param ipAddr the query ip
 * @param ipMask the ip mask,can be 0.
 * @return
 */
public ResponseEntity queryIpAddress(String ipAddr,String ipMask){
  String strIp=ipAddr;
  String strMask=ipMask;
  final long maskHighV6=128;
  final long maskLow=0;
  final long maskHighV4=32;
  long numMask=0;
  if (!StringUtils.isNumeric(ipMask)) {
    return RestResponseUtil.createResponse400();
  }
  if (StringUtils.isNotBlank(ipMask)) {
    numMask=StringUtil.parseUnsignedLong(strMask);
  }
  IpVersion ipVersion=IpVersion.V6;
  boolean isV4=IpUtil.isIpV4StrWholeValid(strIp);
  boolean isV6=IpUtil.isIpV6StrValid(strIp);
  if (!isV4 && !isV6) {
    return RestResponseUtil.createResponse400();
  }
  if (isV4) {
    if (numMask > maskHighV4 || numMask < maskLow) {
      return RestResponseUtil.createResponse400();
    }
    ipVersion=IpVersion.V4;
  }
 else   if (isV6) {
    if (numMask > maskHighV6 || numMask < maskLow) {
      return RestResponseUtil.createResponse400();
    }
    ipVersion=IpVersion.V6;
  }
  StringUtils.lowerCase(strIp);
  QueryParam queryParam=queryParser.parseIpQueryParam(strIp,numMask,ipVersion);
  Network ip=queryService.queryIp(queryParam);
  if (null != ip) {
    if (!accessControlManager.hasPermission(ip)) {
      return RestResponseUtil.createResponse403();
    }
    responseDecorator.decorateResponse(ip);
    return RestResponseUtil.createResponse200(ip);
  }
  LOGGER.debug("String_Node_Str",queryParam);
  RedirectResponse redirect=redirectService.queryIp(queryParam);
  if (null != redirect && StringUtils.isNotBlank(redirect.getUrl())) {
    LOGGER.info("String_Node_Str",redirect.getUrl());
    return RestResponseUtil.createResponse301(redirect.getUrl());
  }
  LOGGER.info("String_Node_Str",queryParam);
  return RestResponseUtil.createResponse404();
}

Fixed version (ground truth):
/** 
 * invoked by upper functions.
 * @param ipAddr the query ip.
 * @param ipMask the ip mask,can be 0.
 * @param originQueryParam originQueryParam.
 * @return ResponseEntity ResponseEntity.
 */
private ResponseEntity queryIpAddress(String ipAddr,String ipMask,String originQueryParam){
  String strIp=ipAddr;
  String strMask=ipMask;
  final long maskHighV6=128;
  final long maskLow=0;
  final long maskHighV4=32;
  long numMask=0;
  if (!StringUtils.isNumeric(ipMask)) {
    return RestResponseUtil.createResponse400();
  }
  if (StringUtils.isNotBlank(ipMask)) {
    numMask=StringUtil.parseUnsignedLong(strMask);
  }
  IpVersion ipVersion=IpVersion.V6;
  boolean isV4=IpUtil.isIpV4StrWholeValid(strIp);
  boolean isV6=IpUtil.isIpV6StrValid(strIp);
  if (!isV4 && !isV6) {
    return RestResponseUtil.createResponse400();
  }
  if (isV4) {
    if (numMask > maskHighV4 || numMask < maskLow) {
      return RestResponseUtil.createResponse400();
    }
    ipVersion=IpVersion.V4;
  }
 else   if (isV6) {
    if (numMask > maskHighV6 || numMask < maskLow) {
      return RestResponseUtil.createResponse400();
    }
    ipVersion=IpVersion.V6;
  }
  StringUtils.lowerCase(strIp);
  QueryParam queryParam=queryParser.parseIpQueryParam(strIp,numMask,ipVersion);
  Network ip=queryService.queryIp(queryParam);
  if (null != ip) {
    if (!accessControlManager.hasPermission(ip)) {
      return RestResponseUtil.createResponse403();
    }
    responseDecorator.decorateResponse(ip);
    return RestResponseUtil.createResponse200(ip);
  }
  LOGGER.debug("String_Node_Str",queryParam);
  RedirectResponse redirect=redirectService.queryIp(queryParam);
  if (null != redirect && StringUtils.isNotBlank(redirect.getUrl())) {
    String redirectUrl=StringUtil.generateEncodedRedirectURL(originQueryParam,SERVICE_URI_IP_Q,redirect.getUrl());
    return RestResponseUtil.createResponse301(redirectUrl);
  }
  LOGGER.info("String_Node_Str",queryParam);
  return RestResponseUtil.createResponse404();
}