[automerger skipped] DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp@6304901 into stag-aosp-master am: d507036def -s ours

am skip reason: subject contains skip directive

Change-Id: I5ea0230421198eb6c798cfd0f3f4562f4dbdb273
diff --git a/src/java/com/android/server/sip/SipService.java b/src/java/com/android/server/sip/SipService.java
index 7c6daf8..ca91943 100644
--- a/src/java/com/android/server/sip/SipService.java
+++ b/src/java/com/android/server/sip/SipService.java
@@ -472,8 +472,8 @@
         mContext.enforceCallingOrSelfPermission(
                 android.Manifest.permission.USE_SIP, message);
 
-        return mAppOps.noteOp(AppOpsManager.OP_USE_SIP, Binder.getCallingUid(),
-                packageName) == AppOpsManager.MODE_ALLOWED;
+        return mAppOps.noteOp(AppOpsManager.OPSTR_USE_SIP, Binder.getCallingUid(),
+                packageName, null, message) == AppOpsManager.MODE_ALLOWED;
     }
 
     private class SipSessionGroupExt extends SipSessionAdapter {
diff --git a/src/jni/rtp/Android.bp b/src/jni/rtp/Android.bp
index c938224..b6c8588 100644
--- a/src/jni/rtp/Android.bp
+++ b/src/jni/rtp/Android.bp
@@ -28,6 +28,7 @@
     ],
     header_libs: [
         "libmedia_headers",
+        "libmediametrics_headers",
     ],
 
     shared_libs: [
diff --git a/src/jni/rtp/AudioGroup.cpp b/src/jni/rtp/AudioGroup.cpp
index 0c97f9f..8bb543c 100644
--- a/src/jni/rtp/AudioGroup.cpp
+++ b/src/jni/rtp/AudioGroup.cpp
@@ -410,20 +410,29 @@
         sockaddr_storage remote;
         socklen_t addrlen = sizeof(remote);
 
-        int length = recvfrom(mSocket, buffer, sizeof(buffer),
+        int bufferSize = sizeof(buffer);
+        int length = recvfrom(mSocket, buffer, bufferSize,
             MSG_TRUNC | MSG_DONTWAIT, (sockaddr *)&remote, &addrlen);
 
         // Do we need to check SSRC, sequence, and timestamp? They are not
         // reliable but at least they can be used to identify duplicates?
-        if (length < 12 || length > (int)sizeof(buffer) ||
+        if (length < 12 || length > bufferSize ||
             (ntohl(*(uint32_t *)buffer) & 0xC07F0000) != mCodecMagic) {
             ALOGV("stream[%d] malformed packet", mSocket);
             return;
         }
         int offset = 12 + ((buffer[0] & 0x0F) << 2);
+        if (offset+2 >= bufferSize) {
+            ALOGV("invalid buffer offset: %d", offset+2);
+            return;
+        }
         if ((buffer[0] & 0x10) != 0) {
             offset += 4 + (ntohs(*(uint16_t *)&buffer[offset + 2]) << 2);
         }
+        if (offset >= bufferSize) {
+            ALOGV("invalid buffer offset: %d", offset);
+            return;
+        }
         if ((buffer[0] & 0x20) != 0) {
             length -= buffer[length - 1];
         }