diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/atcmd.c | 13 | ||||
-rw-r--r-- | src/global.h | 13 | ||||
-rw-r--r-- | src/sms_main.c | 3 |
3 files changed, 17 insertions, 12 deletions
diff --git a/src/atcmd.c b/src/atcmd.c index 694782d..a216ab6 100644 --- a/src/atcmd.c +++ b/src/atcmd.c @@ -1229,8 +1229,7 @@ int atcmd_plus_gmm_read(int fd) log_debug("atcmd_value_tok model"); return -1; } - free(Global.core.model); - Global.core.model = strdup(token); + strncpy(Global.core.model, token, MODEL_LEN); log_debug("model: %s", Global.core.model); @@ -1273,8 +1272,7 @@ int atcmd_plus_gmi_read(int fd) log_debug("atcmd_value_tok manufacturer"); return -1; } - free(Global.core.manufacturer); - Global.core.manufacturer = strdup(token); + strncpy(Global.core.manufacturer, token, MANUFACTURER_LEN); log_debug("manufacturer: %s", Global.core.manufacturer); @@ -1340,8 +1338,7 @@ int atcmd_plus_iccid_read(int fd) token = ++tmp; } log_debug("token[0]=%2.2x token[1]=%2.2x",token[0],token[1]); - free(Global.core.iccid); - Global.core.iccid = strdup(token); + strncpy(Global.core.iccid, token, ICCID_LEN); log_debug("iccid: %s", Global.core.iccid); @@ -1556,7 +1553,7 @@ int isCdmaTypeModel() int is_telit_model() { - if (!strcmp(Global.core.manufacturer, "Telit")) { + if (!strncmp(Global.core.manufacturer, "Telit", MANUFACTURER_LEN)) { log_debug("Found Telit model"); return 1; } @@ -1566,7 +1563,7 @@ int is_telit_model() int is_quectel_model() { - if (!strcmp(Global.core.manufacturer, "Quectel")) { + if (!strncmp(Global.core.manufacturer, "Quectel", MANUFACTURER_LEN)) { log_debug("Found Quectel model"); return 1; } diff --git a/src/global.h b/src/global.h index 764cc06..a6073dd 100644 --- a/src/global.h +++ b/src/global.h @@ -12,6 +12,13 @@ #define GLOBAL_EXTERN extern #endif +#define ICCID_LEN 23 +#define ICCID_SIZE (ICCID_LEN + 1) +#define MODEL_LEN 1023 +#define MODEL_SIZE (MODEL_LEN + 1) +#define MANUFACTURER_LEN 1023 +#define MANUFACTURER_SIZE (MANUFACTURER_LEN + 1) + struct global_user { char *name; char *email; @@ -29,9 +36,9 @@ struct global_core { char *msg_store_send; char *msg_store_new; char *pb_store; - char *model; - char *iccid; /* Needed for LNA3/Verizon */ - char *manufacturer; /* Needed to pick proper manufacturer-specific commands */ + char model[MODEL_SIZE]; + char iccid[ICCID_SIZE]; /* Needed for LNA3/Verizon */ + char manufacturer[MANUFACTURER_SIZE]; /* Needed to pick proper manufacturer-specific commands */ char *editor; char *edit_file; diff --git a/src/sms_main.c b/src/sms_main.c index e91aaba..86116a7 100644 --- a/src/sms_main.c +++ b/src/sms_main.c @@ -59,7 +59,8 @@ static int global_init(void) Global.core.msg_store_send = strdup("SM"); Global.core.msg_store_new = strdup("SM"); Global.core.pb_store = strdup("SM"); - Global.core.model = strdup("UNKNOWNMODEL"); + strncpy(Global.core.model, "UNKNOWNMODEL", MODEL_LEN); + strncpy(Global.core.manufacturer, "UNKNOWNMANUFACTURER", MANUFACTURER_LEN); Global.core.editor = strdup("vi"); Global.core.edit_file = strdup("${HOME}/.smsmsg"); |