Fixed parsing long lines in .conf files

Added an extra parameter to functions used for parsing lines in .conf files, eliminating the fixed number of characters in a line limitation

Bug: 168784564

Test: VtsHalGnssV2_1-TestGnssAntennaInfo is PASS

CRs-fixed: 2779666
Change-Id: Ibe934ea6492325d1cfccce9178979ce2d8ce7db6
diff --git a/gnss/GnssAdapter.cpp b/gnss/GnssAdapter.cpp
index 3d02f97..ece58b4 100644
--- a/gnss/GnssAdapter.cpp
+++ b/gnss/GnssAdapter.cpp
@@ -6109,6 +6109,9 @@
 void
 GnssAdapter::reportGnssAntennaInformation(const antennaInfoCb antennaInfoCallback)
 {
+#define MAX_TEXT_WIDTH      50
+#define MAX_COLUMN_WIDTH    20
+
     /* parse antenna_corrections file and fill in
     a vector of GnssAntennaInformation data structure */
 
@@ -6180,9 +6183,11 @@
         gnssAntennaInfo.phaseCenterOffsetCoordinateMillimeters.z = pcOffset[4];
         gnssAntennaInfo.phaseCenterOffsetCoordinateMillimeters.zUncertainty = pcOffset[5];
 
+        uint16_t array_size = MAX_TEXT_WIDTH + MAX_COLUMN_WIDTH*numberOfColumns;
+        uint16_t array_size_SGC = MAX_TEXT_WIDTH + MAX_COLUMN_WIDTH*numberOfColumnsSGC;
         for (uint32_t j = 0; j < numberOfRows; j++) {
-            char pcVarCorrStr[LOC_MAX_PARAM_STRING];
-            char pcVarCorrUncStr[LOC_MAX_PARAM_STRING];
+            char pcVarCorrStr[array_size];
+            char pcVarCorrUncStr[array_size];
 
             string s1 = "PC_VARIATION_CORRECTION_" + to_string(i) + "_ROW_";
             s1 += to_string(j);
@@ -6194,7 +6199,7 @@
                 { s1.c_str(), &pcVarCorrStr, NULL, 's' },
                 { s2.c_str(), &pcVarCorrUncStr, NULL, 's' },
             };
-            UTIL_READ_CONF(LOC_PATH_ANT_CORR, ant_row_table);
+            UTIL_READ_CONF_LONG(LOC_PATH_ANT_CORR, ant_row_table, array_size);
 
             gnssAntennaInfo.phaseCenterVariationCorrectionMillimeters.push_back(
                     parseDoublesString(pcVarCorrStr));
@@ -6202,8 +6207,8 @@
                     parseDoublesString(pcVarCorrUncStr));
         }
         for (uint32_t j = 0; j < numberOfRowsSGC; j++) {
-            char sigGainCorrStr[LOC_MAX_PARAM_STRING];
-            char sigGainCorrUncStr[LOC_MAX_PARAM_STRING];
+            char sigGainCorrStr[array_size_SGC];
+            char sigGainCorrUncStr[array_size_SGC];
 
             string s3 = "SIGNAL_GAIN_CORRECTION_" + to_string(i) + "_ROW_";
             s3 += to_string(j);
@@ -6215,7 +6220,7 @@
                 { s3.c_str(), &sigGainCorrStr, NULL, 's' },
                 { s4.c_str(), &sigGainCorrUncStr, NULL, 's' },
             };
-            UTIL_READ_CONF(LOC_PATH_ANT_CORR, ant_row_table);
+            UTIL_READ_CONF_LONG(LOC_PATH_ANT_CORR, ant_row_table, array_size_SGC);
 
             gnssAntennaInfo.signalGainCorrectionDbi.push_back(
                     parseDoublesString(sigGainCorrStr));
diff --git a/utils/loc_cfg.cpp b/utils/loc_cfg.cpp
index 987b71a..9ade19d 100644
--- a/utils/loc_cfg.cpp
+++ b/utils/loc_cfg.cpp
@@ -144,7 +144,9 @@
 SIDE EFFECTS
    N/A
 ===========================================================================*/
-int loc_set_config_entry(const loc_param_s_type* config_entry, loc_param_v_type* config_value)
+int loc_set_config_entry(const loc_param_s_type* config_entry,
+                        loc_param_v_type* config_value,
+                        uint16_t string_len = LOC_MAX_PARAM_STRING)
 {
     int ret=-1;
     if(NULL == config_entry || NULL == config_value)
@@ -166,7 +168,7 @@
             else {
                 strlcpy((char*) config_entry->param_ptr,
                         config_value->param_str_value,
-                        LOC_MAX_PARAM_STRING);
+                        string_len);
             }
             /* Log INI values */
             LOC_LOGD("%s: PARAM %s = %s", __FUNCTION__,
@@ -233,7 +235,8 @@
    N/A
 ===========================================================================*/
 int loc_fill_conf_item(char* input_buf,
-                       const loc_param_s_type* config_table, uint32_t table_length)
+                       const loc_param_s_type* config_table,
+                       uint32_t table_length, uint16_t string_len = LOC_MAX_PARAM_STRING)
 {
     int ret = 0;
 
@@ -270,7 +273,7 @@
 
                 for(uint32_t i = 0; NULL != config_table && i < table_length; i++)
                 {
-                    if(!loc_set_config_entry(&config_table[i], &config_value)) {
+                    if(!loc_set_config_entry(&config_table[i], &config_value, string_len)) {
                         ret += 1;
                     }
                 }
@@ -282,7 +285,7 @@
 }
 
 /*===========================================================================
-FUNCTION loc_read_conf_r (repetitive)
+FUNCTION loc_read_conf_r_long (repetitive)
 
 DESCRIPTION
    Reads the specified configuration file and sets defined values based on
@@ -310,11 +313,13 @@
 SIDE EFFECTS
    N/A
 ===========================================================================*/
-int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table, uint32_t table_length)
+int loc_read_conf_r_long(FILE *conf_fp, const loc_param_s_type* config_table,
+                         uint32_t table_length, uint16_t string_len)
 {
     int ret=0;
-
+    char input_buf[string_len];  /* declare a char array */
     unsigned int num_params=table_length;
+
     if(conf_fp == NULL) {
         LOC_LOGE("%s:%d]: ERROR: File pointer is NULL\n", __func__, __LINE__);
         ret = -1;
@@ -330,17 +335,15 @@
         }
     }
 
-    char input_buf[LOC_MAX_PARAM_LINE];  /* declare a char array */
-
     LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
     while(num_params)
     {
-        if(!fgets(input_buf, LOC_MAX_PARAM_LINE, conf_fp)) {
+        if(!fgets(input_buf, string_len, conf_fp)) {
             LOC_LOGD("%s:%d]: fgets returned NULL\n", __func__, __LINE__);
             break;
         }
 
-        num_params -= loc_fill_conf_item(input_buf, config_table, table_length);
+        num_params -= loc_fill_conf_item(input_buf, config_table, table_length, string_len);
     }
 
 err:
@@ -348,7 +351,7 @@
 }
 
 /*===========================================================================
-FUNCTION loc_udpate_conf
+FUNCTION loc_update_conf_long
 
 DESCRIPTION
    Parses the passed in buffer for configuration items, and update the table
@@ -373,8 +376,9 @@
 SIDE EFFECTS
    N/A
 ===========================================================================*/
-int loc_update_conf(const char* conf_data, int32_t length,
-                    const loc_param_s_type* config_table, uint32_t table_length)
+int loc_update_conf_long(const char* conf_data, int32_t length,
+                         const loc_param_s_type* config_table,
+                         uint32_t table_length, uint16_t string_len)
 {
     int ret = -1;
 
@@ -397,7 +401,8 @@
             LOC_LOGD("%s:%d]: num_params: %d\n", __func__, __LINE__, num_params);
             while(num_params && input_buf) {
                 ret++;
-                num_params -= loc_fill_conf_item(input_buf, config_table, table_length);
+                num_params -=
+                        loc_fill_conf_item(input_buf, config_table, table_length, string_len);
                 input_buf = strtok_r(NULL, "\n", &saveptr);
             }
             free(conf_copy);
@@ -408,7 +413,7 @@
 }
 
 /*===========================================================================
-FUNCTION loc_read_conf
+FUNCTION loc_read_conf_long
 
 DESCRIPTION
    Reads the specified configuration file and sets defined values based on
@@ -429,8 +434,8 @@
 SIDE EFFECTS
    N/A
 ===========================================================================*/
-void loc_read_conf(const char* conf_file_name, const loc_param_s_type* config_table,
-                   uint32_t table_length)
+void loc_read_conf_long(const char* conf_file_name, const loc_param_s_type* config_table,
+                        uint32_t table_length, uint16_t string_len)
 {
     FILE *conf_fp = NULL;
 
@@ -439,10 +444,10 @@
     {
         LOC_LOGD("%s: using %s", __FUNCTION__, conf_file_name);
         if(table_length && config_table) {
-            loc_read_conf_r(conf_fp, config_table, table_length);
+            loc_read_conf_r_long(conf_fp, config_table, table_length, string_len);
             rewind(conf_fp);
         }
-        loc_read_conf_r(conf_fp, loc_param_table, loc_param_num);
+        loc_read_conf_r_long(conf_fp, loc_param_table, loc_param_num, string_len);
         fclose(conf_fp);
     }
     /* Initialize logging mechanism with parsed data */
diff --git a/utils/loc_cfg.h b/utils/loc_cfg.h
index ea5a97a..e87d632 100644
--- a/utils/loc_cfg.h
+++ b/utils/loc_cfg.h
@@ -65,6 +65,10 @@
 #define UTIL_READ_CONF(filename, config_table) \
     loc_read_conf((filename), (&config_table[0]), sizeof(config_table) / sizeof(config_table[0]))
 
+#define UTIL_READ_CONF_LONG(filename, config_table, rec_len) \
+    loc_read_conf_long((filename), (&config_table[0]), \
+            sizeof(config_table) / sizeof(config_table[0]), (rec_len))
+
 /*=============================================================================
  *
  *                        MODULE TYPE DECLARATION
@@ -115,13 +119,30 @@
  *============================================================================*/
 bool isVendorEnhanced();
 void setVendorEnhanced(bool vendorEnhanced);
-void loc_read_conf(const char* conf_file_name,
-                   const loc_param_s_type* config_table,
-                   uint32_t table_length);
-int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table,
-                    uint32_t table_length);
-int loc_update_conf(const char* conf_data, int32_t length,
-                    const loc_param_s_type* config_table, uint32_t table_length);
+void loc_read_conf_long(const char* conf_file_name,
+                        const loc_param_s_type* config_table,
+                        uint32_t table_length, uint16_t string_len);
+int loc_read_conf_r_long(FILE *conf_fp, const loc_param_s_type* config_table,
+                         uint32_t table_length, uint16_t string_len);
+int loc_update_conf_long(const char* conf_data, int32_t length,
+                         const loc_param_s_type* config_table, uint32_t table_length,
+                         uint16_t string_len);
+
+inline void loc_read_conf(const char* conf_file_name,
+                          const loc_param_s_type* config_table, uint32_t table_length) {
+    loc_read_conf_long(conf_file_name, config_table, table_length, LOC_MAX_PARAM_STRING);
+}
+
+inline int loc_read_conf_r(FILE *conf_fp, const loc_param_s_type* config_table,
+                    uint32_t table_length) {
+    return (loc_read_conf_r_long(conf_fp, config_table, table_length, LOC_MAX_PARAM_STRING));
+}
+
+inline int loc_update_conf(const char* conf_data, int32_t length,
+                    const loc_param_s_type* config_table, uint32_t table_length) {
+    return (loc_update_conf_long(
+                    conf_data, length, config_table, table_length, LOC_MAX_PARAM_STRING));
+}
 
 // Below are the location conf file paths
 extern const char LOC_PATH_GPS_CONF[];