Program: 84966
Project: 84966
Buggy source:
@Override public int onPut(Operation op){
  if (Constants.LOGV) {
    Log.v(TAG,"String_Node_Str" + op.toString());
  }
  HeaderSet request;
  String name, mimeType;
  Long length;
  int obexResponse=ResponseCodes.OBEX_HTTP_OK;
  if (mAccepted == BluetoothShare.USER_CONFIRMATION_DENIED) {
    return ResponseCodes.OBEX_HTTP_FORBIDDEN;
  }
  try {
    boolean pre_reject=false;
    request=op.getReceivedHeader();
    if (Constants.LOGVV) {
      logHeader(request);
    }
    name=(String)request.getHeader(HeaderSet.NAME);
    length=(Long)request.getHeader(HeaderSet.LENGTH);
    mimeType=(String)request.getHeader(HeaderSet.TYPE);
    if (length == 0) {
      if (Constants.LOGV) {
        Log.w(TAG,"String_Node_Str");
      }
      pre_reject=true;
      obexResponse=ResponseCodes.OBEX_HTTP_LENGTH_REQUIRED;
    }
    if (name == null || name.equals("String_Node_Str")) {
      if (Constants.LOGV) {
        Log.w(TAG,"String_Node_Str");
      }
      pre_reject=true;
      obexResponse=ResponseCodes.OBEX_HTTP_BAD_REQUEST;
    }
    if (!pre_reject) {
      String extension, type;
      int dotIndex=name.indexOf('.');
      if (dotIndex < 0) {
        if (Constants.LOGV) {
          Log.w(TAG,"String_Node_Str");
        }
        pre_reject=true;
        obexResponse=ResponseCodes.OBEX_HTTP_BAD_REQUEST;
      }
 else {
        extension=name.substring(dotIndex + 1);
        MimeTypeMap map=MimeTypeMap.getSingleton();
        type=map.getMimeTypeFromExtension(extension);
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + extension + "String_Node_Str"+ type);
        }
        if (type != null) {
          mimeType=type;
        }
 else {
          if (mimeType == null) {
            if (Constants.LOGV) {
              Log.w(TAG,"String_Node_Str");
            }
            pre_reject=true;
            obexResponse=ResponseCodes.OBEX_HTTP_UNSUPPORTED_TYPE;
          }
        }
        if (mimeType != null) {
          mimeType=mimeType.toLowerCase();
        }
      }
    }
    if (!pre_reject && (mimeType == null || Constants.mimeTypeMatches(mimeType,Constants.UNACCEPTABLE_SHARE_INBOUND_TYPES))) {
      if (Constants.LOGV) {
        Log.w(TAG,"String_Node_Str");
      }
      pre_reject=true;
      obexResponse=ResponseCodes.OBEX_HTTP_UNSUPPORTED_TYPE;
    }
    if (pre_reject && obexResponse != ResponseCodes.OBEX_HTTP_OK) {
      return obexResponse;
    }
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + e);
    return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
  }
  ContentValues values=new ContentValues();
  values.put(BluetoothShare.FILENAME_HINT,name);
  values.put(BluetoothShare.TOTAL_BYTES,length.intValue());
  values.put(BluetoothShare.MIMETYPE,mimeType);
  if (mTransport instanceof BluetoothOppRfcommTransport) {
    String a=((BluetoothOppRfcommTransport)mTransport).getRemoteAddress();
    values.put(BluetoothShare.DESTINATION,a);
  }
 else {
    values.put(BluetoothShare.DESTINATION,"String_Node_Str");
  }
  values.put(BluetoothShare.DIRECTION,BluetoothShare.DIRECTION_INBOUND);
  values.put(BluetoothShare.TIMESTAMP,mTimestamp);
  boolean needConfirm=true;
  if (!mServerBlocking) {
    values.put(BluetoothShare.USER_CONFIRMATION,BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED);
    needConfirm=false;
  }
  Uri contentUri=mContext.getContentResolver().insert(BluetoothShare.CONTENT_URI,values);
  mLocalShareInfoId=Integer.parseInt(contentUri.getPathSegments().get(1));
  if (needConfirm) {
    Intent in=new Intent(BluetoothShare.INCOMING_FILE_CONFIRMATION_REQUEST_ACTION);
    in.setClassName(Constants.THIS_PACKAGE_NAME,BluetoothOppReceiver.class.getName());
    mContext.sendBroadcast(in);
  }
  if (Constants.LOGVV) {
    Log.v(TAG,"String_Node_Str" + contentUri);
    Log.v(TAG,"String_Node_Str" + mLocalShareInfoId);
  }
  mServerBlocking=true;
  boolean msgSent=false;
synchronized (this) {
    try {
      while (mServerBlocking) {
        wait(1000);
        if (mCallback != null && !msgSent) {
          mCallback.sendMessageDelayed(mCallback.obtainMessage(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT),BluetoothOppObexSession.SESSION_TIMEOUT);
          msgSent=true;
          if (Constants.LOGVV) {
            Log.v(TAG,"String_Node_Str");
          }
        }
      }
    }
 catch (    InterruptedException e) {
      if (Constants.LOGVV) {
        Log.v(TAG,"String_Node_Str");
      }
    }
  }
  if (Constants.LOGV) {
    Log.v(TAG,"String_Node_Str");
  }
  if (mCallback != null && msgSent) {
    mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
  }
  if (mInfo.mId != mLocalShareInfoId) {
    Log.e(TAG,"String_Node_Str");
  }
  mAccepted=mInfo.mConfirm;
  if (Constants.LOGVV) {
    Log.v(TAG,"String_Node_Str" + mAccepted);
  }
  int status=BluetoothShare.STATUS_SUCCESS;
  if (mAccepted == BluetoothShare.USER_CONFIRMATION_CONFIRMED || mAccepted == BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED) {
    if (mFileInfo.mFileName == null) {
      status=mFileInfo.mStatus;
      mInfo.mStatus=mFileInfo.mStatus;
      Constants.updateShareStatus(mContext,mInfo.mId,status);
      obexResponse=ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
    }
    if (mFileInfo.mFileName != null) {
      ContentValues updateValues=new ContentValues();
      contentUri=Uri.parse(BluetoothShare.CONTENT_URI + "String_Node_Str" + mInfo.mId);
      updateValues.put(BluetoothShare._DATA,mFileInfo.mFileName);
      updateValues.put(BluetoothShare.STATUS,BluetoothShare.STATUS_RUNNING);
      mContext.getContentResolver().update(contentUri,updateValues,null,null);
      status=receiveFile(mFileInfo,op);
      if (status != BluetoothShare.STATUS_SUCCESS) {
        obexResponse=ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
      }
      Constants.updateShareStatus(mContext,mInfo.mId,status);
    }
    if (status == BluetoothShare.STATUS_SUCCESS) {
      Message msg=Message.obtain(mCallback,BluetoothOppObexSession.MSG_SHARE_COMPLETE);
      msg.obj=mInfo;
      msg.sendToTarget();
    }
 else {
      Message msg=Message.obtain(mCallback,BluetoothOppObexSession.MSG_SESSION_ERROR);
      msg.obj=mInfo;
      msg.sendToTarget();
    }
  }
 else   if (mAccepted == BluetoothShare.USER_CONFIRMATION_DENIED || mAccepted == BluetoothShare.USER_CONFIRMATION_TIMEOUT) {
    if (Constants.LOGVV) {
      Log.v(TAG,"String_Node_Str");
    }
    status=BluetoothShare.STATUS_FORBIDDEN;
    Constants.updateShareStatus(mContext,mInfo.mId,status);
    obexResponse=ResponseCodes.OBEX_HTTP_FORBIDDEN;
    Message msg=Message.obtain(mCallback);
    msg.what=BluetoothOppObexSession.MSG_SHARE_INTERRUPTED;
    msg.obj=mInfo;
    msg.sendToTarget();
  }
  return obexResponse;
}

Fixed version (ground truth):
@Override public int onPut(Operation op){
  if (Constants.LOGV) {
    Log.v(TAG,"String_Node_Str" + op.toString());
  }
  HeaderSet request;
  String name, mimeType;
  Long length;
  int obexResponse=ResponseCodes.OBEX_HTTP_OK;
  if (mAccepted == BluetoothShare.USER_CONFIRMATION_DENIED) {
    return ResponseCodes.OBEX_HTTP_FORBIDDEN;
  }
  try {
    boolean pre_reject=false;
    request=op.getReceivedHeader();
    if (Constants.LOGVV) {
      logHeader(request);
    }
    name=(String)request.getHeader(HeaderSet.NAME);
    length=(Long)request.getHeader(HeaderSet.LENGTH);
    mimeType=(String)request.getHeader(HeaderSet.TYPE);
    if (length == 0) {
      if (Constants.LOGV) {
        Log.w(TAG,"String_Node_Str");
      }
      pre_reject=true;
      obexResponse=ResponseCodes.OBEX_HTTP_LENGTH_REQUIRED;
    }
    if (name == null || name.equals("String_Node_Str")) {
      if (Constants.LOGV) {
        Log.w(TAG,"String_Node_Str");
      }
      pre_reject=true;
      obexResponse=ResponseCodes.OBEX_HTTP_BAD_REQUEST;
    }
    if (!pre_reject) {
      String extension, type;
      int dotIndex=name.indexOf('.');
      if (dotIndex < 0) {
        if (Constants.LOGV) {
          Log.w(TAG,"String_Node_Str");
        }
        pre_reject=true;
        obexResponse=ResponseCodes.OBEX_HTTP_BAD_REQUEST;
      }
 else {
        extension=name.substring(dotIndex + 1);
        MimeTypeMap map=MimeTypeMap.getSingleton();
        type=map.getMimeTypeFromExtension(extension);
        if (Constants.LOGVV) {
          Log.v(TAG,"String_Node_Str" + extension + "String_Node_Str"+ type);
        }
        if (type != null) {
          mimeType=type;
        }
 else {
          if (mimeType == null) {
            if (Constants.LOGV) {
              Log.w(TAG,"String_Node_Str");
            }
            pre_reject=true;
            obexResponse=ResponseCodes.OBEX_HTTP_UNSUPPORTED_TYPE;
          }
        }
        if (mimeType != null) {
          mimeType=mimeType.toLowerCase();
        }
      }
    }
    if (!pre_reject && (mimeType == null || Constants.mimeTypeMatches(mimeType,Constants.UNACCEPTABLE_SHARE_INBOUND_TYPES))) {
      if (Constants.LOGV) {
        Log.w(TAG,"String_Node_Str");
      }
      pre_reject=true;
      obexResponse=ResponseCodes.OBEX_HTTP_UNSUPPORTED_TYPE;
    }
    if (pre_reject && obexResponse != ResponseCodes.OBEX_HTTP_OK) {
      return obexResponse;
    }
  }
 catch (  IOException e) {
    Log.e(TAG,"String_Node_Str" + e);
    return ResponseCodes.OBEX_HTTP_BAD_REQUEST;
  }
  ContentValues values=new ContentValues();
  values.put(BluetoothShare.FILENAME_HINT,name);
  values.put(BluetoothShare.TOTAL_BYTES,length.intValue());
  values.put(BluetoothShare.MIMETYPE,mimeType);
  if (mTransport instanceof BluetoothOppRfcommTransport) {
    String a=((BluetoothOppRfcommTransport)mTransport).getRemoteAddress();
    values.put(BluetoothShare.DESTINATION,a);
  }
 else {
    values.put(BluetoothShare.DESTINATION,"String_Node_Str");
  }
  values.put(BluetoothShare.DIRECTION,BluetoothShare.DIRECTION_INBOUND);
  values.put(BluetoothShare.TIMESTAMP,mTimestamp);
  boolean needConfirm=true;
  if (!mServerBlocking) {
    values.put(BluetoothShare.USER_CONFIRMATION,BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED);
    needConfirm=false;
  }
  Uri contentUri=mContext.getContentResolver().insert(BluetoothShare.CONTENT_URI,values);
  mLocalShareInfoId=Integer.parseInt(contentUri.getPathSegments().get(1));
  if (needConfirm) {
    Intent in=new Intent(BluetoothShare.INCOMING_FILE_CONFIRMATION_REQUEST_ACTION);
    in.setClassName(Constants.THIS_PACKAGE_NAME,BluetoothOppReceiver.class.getName());
    mContext.sendBroadcast(in);
  }
  if (Constants.LOGVV) {
    Log.v(TAG,"String_Node_Str" + contentUri);
    Log.v(TAG,"String_Node_Str" + mLocalShareInfoId);
  }
  if (Constants.LOGVV) {
    Log.v(TAG,"String_Node_Str");
  }
  if (mWakeLock.isHeld()) {
    mPartialWakeLock.acquire();
    mWakeLock.release();
  }
  mServerBlocking=true;
  boolean msgSent=false;
synchronized (this) {
    try {
      while (mServerBlocking) {
        wait(1000);
        if (mCallback != null && !msgSent) {
          mCallback.sendMessageDelayed(mCallback.obtainMessage(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT),BluetoothOppObexSession.SESSION_TIMEOUT);
          msgSent=true;
          if (Constants.LOGVV) {
            Log.v(TAG,"String_Node_Str");
          }
        }
      }
    }
 catch (    InterruptedException e) {
      if (Constants.LOGVV) {
        Log.v(TAG,"String_Node_Str");
      }
    }
  }
  if (Constants.LOGV) {
    Log.v(TAG,"String_Node_Str");
  }
  if (mCallback != null && msgSent) {
    mCallback.removeMessages(BluetoothOppObexSession.MSG_CONNECT_TIMEOUT);
  }
  if (mInfo.mId != mLocalShareInfoId) {
    Log.e(TAG,"String_Node_Str");
  }
  mAccepted=mInfo.mConfirm;
  if (Constants.LOGVV) {
    Log.v(TAG,"String_Node_Str" + mAccepted);
  }
  int status=BluetoothShare.STATUS_SUCCESS;
  if (mAccepted == BluetoothShare.USER_CONFIRMATION_CONFIRMED || mAccepted == BluetoothShare.USER_CONFIRMATION_AUTO_CONFIRMED) {
    if (mFileInfo.mFileName == null) {
      status=mFileInfo.mStatus;
      mInfo.mStatus=mFileInfo.mStatus;
      Constants.updateShareStatus(mContext,mInfo.mId,status);
      obexResponse=ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
    }
    if (mFileInfo.mFileName != null) {
      ContentValues updateValues=new ContentValues();
      contentUri=Uri.parse(BluetoothShare.CONTENT_URI + "String_Node_Str" + mInfo.mId);
      updateValues.put(BluetoothShare._DATA,mFileInfo.mFileName);
      updateValues.put(BluetoothShare.STATUS,BluetoothShare.STATUS_RUNNING);
      mContext.getContentResolver().update(contentUri,updateValues,null,null);
      status=receiveFile(mFileInfo,op);
      if (status != BluetoothShare.STATUS_SUCCESS) {
        obexResponse=ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
      }
      Constants.updateShareStatus(mContext,mInfo.mId,status);
    }
    if (status == BluetoothShare.STATUS_SUCCESS) {
      Message msg=Message.obtain(mCallback,BluetoothOppObexSession.MSG_SHARE_COMPLETE);
      msg.obj=mInfo;
      msg.sendToTarget();
    }
 else {
      Message msg=Message.obtain(mCallback,BluetoothOppObexSession.MSG_SESSION_ERROR);
      msg.obj=mInfo;
      msg.sendToTarget();
    }
  }
 else   if (mAccepted == BluetoothShare.USER_CONFIRMATION_DENIED || mAccepted == BluetoothShare.USER_CONFIRMATION_TIMEOUT) {
    Log.i(TAG,"String_Node_Str");
    status=BluetoothShare.STATUS_FORBIDDEN;
    Constants.updateShareStatus(mContext,mInfo.mId,status);
    obexResponse=ResponseCodes.OBEX_HTTP_FORBIDDEN;
    Message msg=Message.obtain(mCallback);
    msg.what=BluetoothOppObexSession.MSG_SHARE_INTERRUPTED;
    msg.obj=mInfo;
    msg.sendToTarget();
  }
  return obexResponse;
}