From: Thomas F. <tlf...@li...> - 2014-06-20 20:22:51
|
rtas_get_sysparm and rtas_set_sysparm commands both manipulate buffers in which the first two bytes are a big endian integer indicating the size of the remaining buffer. This patch makes sure those bytes are in the correct format. Signed-off-by: Thomas Falcon <tlf...@li...> --- src/serv_config.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/serv_config.c b/src/serv_config.c index 5a7b97b..2644d90 100644 --- a/src/serv_config.c +++ b/src/serv_config.c @@ -674,7 +674,7 @@ retrieve_value(struct service_var *var, char *buf, size_t size) { if (var->sysparm_num == USE_CALL_HOME_SYSPARM) break; - ret_size = *(uint16_t *)param; + ret_size = be16toh(*(uint16_t *)param); if (!strcmp(var->nvram_var, "sp-ri-pon") || !strcmp(var->nvram_var, "sp-remote-pon") || !strcmp(var->nvram_var, "sp-sen")) { @@ -825,7 +825,7 @@ update_value(struct service_var *var, char *val) { if (!strcmp(var->nvram_var, "sp-ri-pon") || !strcmp(var->nvram_var, "sp-remote-pon") || !strcmp(var->nvram_var, "sp-sen")) { - *(uint16_t *)param = 1; + *(uint16_t *)param = htobe16(1); if (!strcmp(val, "on")) param[2] = (uint8_t)(1); if (!strcmp(val, "off")) @@ -837,11 +837,11 @@ update_value(struct service_var *var, char *val) { (var->type == TYPE_NUM_1_120) || (var->type == TYPE_NUM_1_255)) { - *(uint16_t *)param = 1; + *(uint16_t *)param = htobe16(1); param[2] = (uint8_t)atoi(val); } else { - *(uint16_t *)param = sizeof(val); + *(uint16_t *)param = htobe16(sizeof(val)); strncpy(param+2, val, BUF_SIZE-2); } -- 1.8.5.2 |