From fb9c641bb869301c9b3728608870673693ff593f Mon Sep 17 00:00:00 2001 From: Kevin Tang Date: Fri, 10 Oct 2014 10:35:28 -0700 Subject: [PATCH 1/2] Added Detection Logic For QMI_PDS Target. Added run time detection of PDS enabled fusion target to loc_target(), to support fusion platforms that has PDS service enabled. Change-Id: Ic53df027540f00eec9259776351b6bbc9afa0521 CRs-Fixed: 699757 --- utils/loc_target.cpp | 9 +++++++-- utils/loc_target.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/utils/loc_target.cpp b/utils/loc_target.cpp index d46747ac..8dbe885e 100644 --- a/utils/loc_target.cpp +++ b/utils/loc_target.cpp @@ -46,6 +46,7 @@ #define MSM8930_ID_2 "116" #define APQ8030_ID_1 "157" #define APQ8074_ID_1 "184" +#define PDS_ID_1 "178" #define LINE_LEN 100 #define STR_LIQUID "Liquid" @@ -206,8 +207,12 @@ unsigned int loc_get_target(void) } else { read_a_line(id_dep, rd_id, LINE_LEN); } - - if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){ + if( !memcmp(rd_hw_platform, STR_MTP, LENGTH(STR_MTP)) ){ + if( !memcmp(rd_id, PDS_ID_1, LENGTH(PDS_ID_1)) + && IS_STR_END(rd_id[LENGTH(PDS_ID_1)]) ) + gTarget = TARGET_PDS; + } + else if( !memcmp(baseband, STR_APQ, LENGTH(STR_APQ)) ){ if( !memcmp(rd_id, MPQ8064_ID_1, LENGTH(MPQ8064_ID_1)) && IS_STR_END(rd_id[LENGTH(MPQ8064_ID_1)]) ) gTarget = TARGET_MPQ; diff --git a/utils/loc_target.h b/utils/loc_target.h index 9aa525fc..208a34cb 100644 --- a/utils/loc_target.h +++ b/utils/loc_target.h @@ -35,6 +35,7 @@ #define TARGET_MPQ TARGET_SET(GNSS_NONE,NO_SSC) #define TARGET_MSM_NO_SSC TARGET_SET(GNSS_MSM, NO_SSC) #define TARGET_QCA1530 TARGET_SET(GNSS_QCA1530, NO_SSC) +#define TARGET_PDS TARGET_SET(GNSS_PDS, NO_SSC) #define TARGET_UNKNOWN TARGET_SET(GNSS_UNKNOWN, NO_SSC) #define getTargetGnssType(target) (target>>1) @@ -60,6 +61,7 @@ typedef enum { GNSS_GSS, GNSS_MDM, GNSS_QCA1530, + GNSS_PDS, GNSS_UNKNOWN }GNSS_TARGET; From 0b0b89fbd646ab05433a12ed1cced5e240cad277 Mon Sep 17 00:00:00 2001 From: Tushar Janefalkar Date: Wed, 14 Nov 2012 11:32:40 -0800 Subject: [PATCH 2/2] Add buffer length check for XTRA data To prevent reading beyond the length of the buffer that contains XTRA data, a check has been introduced assuming an approximate limit for the size of the data Change-Id: I7e05beadec76c3308448b9198fd23c8e8b97394d CRs-fixed: 420623 --- loc_api/libloc_api_50001/loc.cpp | 8 ++++++-- loc_api/libloc_api_50001/loc.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/loc_api/libloc_api_50001/loc.cpp b/loc_api/libloc_api_50001/loc.cpp index f9a2133a..65e1bf16 100644 --- a/loc_api/libloc_api_50001/loc.cpp +++ b/loc_api/libloc_api_50001/loc.cpp @@ -855,8 +855,12 @@ SIDE EFFECTS static int loc_xtra_inject_data(char* data, int length) { ENTRY_LOG(); - int ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length); - + int ret_val = -1; + if( (data != NULL) && ((unsigned int)length <= XTRA_DATA_MAX_SIZE)) + ret_val = loc_eng_xtra_inject_data(loc_afw_data, data, length); + else + LOC_LOGE("%s, Could not inject XTRA data. Buffer address: %p, length: %d", + __func__, data, length); EXIT_LOG(%d, ret_val); return ret_val; } diff --git a/loc_api/libloc_api_50001/loc.h b/loc_api/libloc_api_50001/loc.h index 7e268273..63528664 100644 --- a/loc_api/libloc_api_50001/loc.h +++ b/loc_api/libloc_api_50001/loc.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011,2014 The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -39,6 +39,8 @@ extern "C" { #include #include +#define XTRA_DATA_MAX_SIZE 100000 /*bytes*/ + typedef void (*loc_location_cb_ext) (UlpLocation* location, void* locExt); typedef void (*loc_sv_status_cb_ext) (GpsSvStatus* sv_status, void* svExt); typedef void* (*loc_ext_parser)(void* data);