GPS: unify buffer size passed to retrieve string with loc cfg
Loc cfg parsing routines assuming that string buffer size is LOC_MAX_PARAM_STRING. Changes are to make sure that caller to loc cfg routine does use that buffer of size LOC_MAX_PARAM_STRING. Change-Id: Icecf6bf017e6dda1da0766adc746f60d471653d0 CRs-fixed: 2301437
This commit is contained in:
parent
d2980eb906
commit
0a19651316
4 changed files with 14 additions and 20 deletions
|
@ -36,9 +36,6 @@
|
||||||
#include <LBSProxyBase.h>
|
#include <LBSProxyBase.h>
|
||||||
#include <loc_cfg.h>
|
#include <loc_cfg.h>
|
||||||
|
|
||||||
#define MAX_XTRA_SERVER_URL_LENGTH (256)
|
|
||||||
#define MAX_SUPL_SERVER_URL_LENGTH (256)
|
|
||||||
|
|
||||||
/* GPS.conf support */
|
/* GPS.conf support */
|
||||||
/* NOTE: the implementaiton of the parser casts number
|
/* NOTE: the implementaiton of the parser casts number
|
||||||
fields to 32 bit. To ensure all 'n' fields working,
|
fields to 32 bit. To ensure all 'n' fields working,
|
||||||
|
@ -53,9 +50,9 @@ typedef struct loc_gps_cfg_s
|
||||||
uint32_t CAPABILITIES;
|
uint32_t CAPABILITIES;
|
||||||
uint32_t LPP_PROFILE;
|
uint32_t LPP_PROFILE;
|
||||||
uint32_t XTRA_VERSION_CHECK;
|
uint32_t XTRA_VERSION_CHECK;
|
||||||
char XTRA_SERVER_1[MAX_XTRA_SERVER_URL_LENGTH];
|
char XTRA_SERVER_1[LOC_MAX_PARAM_STRING];
|
||||||
char XTRA_SERVER_2[MAX_XTRA_SERVER_URL_LENGTH];
|
char XTRA_SERVER_2[LOC_MAX_PARAM_STRING];
|
||||||
char XTRA_SERVER_3[MAX_XTRA_SERVER_URL_LENGTH];
|
char XTRA_SERVER_3[LOC_MAX_PARAM_STRING];
|
||||||
uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;
|
uint32_t USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL;
|
||||||
uint32_t NMEA_PROVIDER;
|
uint32_t NMEA_PROVIDER;
|
||||||
uint32_t GPS_LOCK;
|
uint32_t GPS_LOCK;
|
||||||
|
@ -65,10 +62,10 @@ typedef struct loc_gps_cfg_s
|
||||||
uint32_t LPPE_CP_TECHNOLOGY;
|
uint32_t LPPE_CP_TECHNOLOGY;
|
||||||
uint32_t LPPE_UP_TECHNOLOGY;
|
uint32_t LPPE_UP_TECHNOLOGY;
|
||||||
uint32_t EXTERNAL_DR_ENABLED;
|
uint32_t EXTERNAL_DR_ENABLED;
|
||||||
char SUPL_HOST[MAX_SUPL_SERVER_URL_LENGTH];
|
char SUPL_HOST[LOC_MAX_PARAM_STRING];
|
||||||
uint32_t SUPL_PORT;
|
uint32_t SUPL_PORT;
|
||||||
uint32_t MODEM_TYPE;
|
uint32_t MODEM_TYPE;
|
||||||
char MO_SUPL_HOST[MAX_SUPL_SERVER_URL_LENGTH];
|
char MO_SUPL_HOST[LOC_MAX_PARAM_STRING];
|
||||||
uint32_t MO_SUPL_PORT;
|
uint32_t MO_SUPL_PORT;
|
||||||
} loc_gps_cfg_s_type;
|
} loc_gps_cfg_s_type;
|
||||||
|
|
||||||
|
|
|
@ -629,10 +629,7 @@ GnssAdapter::setSuplHostServer(const char* server, int port, LocServerType type)
|
||||||
url.assign(serverUrl);
|
url.assign(serverUrl);
|
||||||
|
|
||||||
if (LOC_AGPS_SUPL_SERVER == type) {
|
if (LOC_AGPS_SUPL_SERVER == type) {
|
||||||
int nCharsToCopy = strlen(server) < MAX_SUPL_SERVER_URL_LENGTH ?
|
strlcpy(ContextBase::mGps_conf.SUPL_HOST, server, LOC_MAX_PARAM_STRING);
|
||||||
strlen(server) : (MAX_SUPL_SERVER_URL_LENGTH - 1);
|
|
||||||
strlcpy(ContextBase::mGps_conf.SUPL_HOST, server, nCharsToCopy);
|
|
||||||
ContextBase::mGps_conf.SUPL_HOST[nCharsToCopy] = '\0';
|
|
||||||
ContextBase::mGps_conf.SUPL_PORT = port;
|
ContextBase::mGps_conf.SUPL_PORT = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,7 +141,7 @@ int loc_set_config_entry(const loc_param_s_type* config_entry, loc_param_v_type*
|
||||||
else {
|
else {
|
||||||
strlcpy((char*) config_entry->param_ptr,
|
strlcpy((char*) config_entry->param_ptr,
|
||||||
config_value->param_str_value,
|
config_value->param_str_value,
|
||||||
LOC_MAX_PARAM_STRING + 1);
|
LOC_MAX_PARAM_STRING);
|
||||||
}
|
}
|
||||||
/* Log INI values */
|
/* Log INI values */
|
||||||
LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__,
|
LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__,
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
|
|
||||||
#define LOC_MAX_PARAM_NAME 80
|
#define LOC_MAX_PARAM_NAME 80
|
||||||
#define LOC_MAX_PARAM_STRING 170
|
#define LOC_MAX_PARAM_STRING 172
|
||||||
#define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING)
|
#define LOC_MAX_PARAM_LINE (LOC_MAX_PARAM_NAME + LOC_MAX_PARAM_STRING)
|
||||||
|
|
||||||
#define LOC_FEATURE_MODE_DISABLED "DISABLED"
|
#define LOC_FEATURE_MODE_DISABLED "DISABLED"
|
||||||
|
@ -72,12 +72,12 @@
|
||||||
*============================================================================*/
|
*============================================================================*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const char *param_name;
|
const char *param_name;
|
||||||
void *param_ptr;
|
void *param_ptr; /* for string type, buf size need to be LOC_MAX_PARAM_STRING */
|
||||||
uint8_t *param_set; /* indicate value set by config file */
|
uint8_t *param_set; /* indicate value set by config file */
|
||||||
char param_type; /* 'n' for number,
|
char param_type; /* 'n' for number,
|
||||||
's' for string,
|
's' for string, NOTE: buf size need to be LOC_MAX_PARAM_STRING
|
||||||
'f' for double */
|
'f' for double */
|
||||||
} loc_param_s_type;
|
} loc_param_s_type;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
Loading…
Reference in a new issue