【发布时间】:2011-09-24 23:46:43
【问题描述】:
问候stackoverflow。
最近在跟踪Android框架中的蓝牙运行机制。我注意到this patch 在通过 OPP 接收文件时有一些文件类型限制。
在 com.android.bluetooth.opp 包中,Constants.java 中有一个固定的白名单
/**
* The MIME type(s) of we could accept from other device.
* This is in essence a "white list" of acceptable types.
* Today, restricted to images, audio, video and certain text types.
*/
public static final String[] ACCEPTABLE_SHARE_INBOUND_TYPES = new String[] {
/* ... some types such as images and music ... */
};
这限制了 BluetoothOppObexServerSession.java 中可接受的文件类型
// Reject policy: anything outside the "white list" plus unspecified
// MIME Types.
if (!pre_reject
&& (mimeType == null || (!Constants.mimeTypeMatches(mimeType,
Constants.ACCEPTABLE_SHARE_INBOUND_TYPES)))) {
if (D) Log.w(TAG, "mimeType is null or in unacceptable list, reject the transfer");
pre_reject = true;
obexResponse = ResponseCodes.OBEX_HTTP_UNSUPPORTED_TYPE;
在这种情况下,是什么让我们担心 MIME 类型?据我所知,我们可能希望阻止可执行文件(即 *.apk、*.so),因为这些文件可能会损害我们的设备。如果阻止某些特定类型是我们在这里设置列表的原因,为什么我们会在此补丁之前使用白名单而不是黑名单?当我们通过 HTTP 等其他非蓝牙协议传输文件时,是否有类似的限制?
【问题讨论】:
标签: android security bluetooth obex