summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Eversberg <jolly@eversberg.eu>2016-09-25 08:09:38 +0200
committerAndreas Eversberg <jolly@eversberg.eu>2016-09-25 08:29:14 +0200
commitc1dec9c2be8bd3392814547b5e3d3dd5f9b71c5e (patch)
tree7a3984ba9363857957b592b434edab6802a97180
parent2f5c76a9946dd97866deda70a6f777c63fb9be49 (diff)
mobile/gui: Fix overlapping memcpy that trashed stringsjolly/ui
-rw-r--r--src/host/layer23/src/mobile/gui.c12
-rw-r--r--src/host/layer23/src/ui/ui.c8
2 files changed, 10 insertions, 10 deletions
diff --git a/src/host/layer23/src/mobile/gui.c b/src/host/layer23/src/mobile/gui.c
index 6f354ac..2ac7e40 100644
--- a/src/host/layer23/src/mobile/gui.c
+++ b/src/host/layer23/src/mobile/gui.c
@@ -117,7 +117,7 @@ static int status_netname(struct osmocom_ms *ms, char *text)
len = strlen(text);
if (len + 1 < UI_COLS) {
shift = (UI_COLS - len) / 2;
- memcpy(text + shift, text, len + 1);
+ memmove(text + shift, text, len + 1);
memset(text, ' ', shift);
}
@@ -150,7 +150,7 @@ static int status_imsi(struct osmocom_ms *ms, char *text)
len = strlen(text);
/* wrap */
if (len > UI_COLS) {
- memcpy(text + UI_COLS + 1, text + UI_COLS, len - UI_COLS + 1);
+ memmove(text + UI_COLS + 1, text + UI_COLS, len - UI_COLS + 1);
text[UI_COLS] = '\0';
text[2 * UI_COLS + 1] = '\0';
@@ -169,7 +169,7 @@ static int status_imei(struct osmocom_ms *ms, char *text)
len = strlen(text);
/* wrap */
if (len > UI_COLS) {
- memcpy(text + UI_COLS + 1, text + UI_COLS, len - UI_COLS + 1);
+ memmove(text + UI_COLS + 1, text + UI_COLS, len - UI_COLS + 1);
text[UI_COLS] = '\0';
text[2 * UI_COLS + 1] = '\0';
@@ -1812,7 +1812,7 @@ int gui_notify_call(struct osmocom_ms *ms)
len = strlen(p);
if (len + 1 < UI_COLS) {
shift = (UI_COLS - len) / 2;
- memcpy(p + shift, p, len + 1);
+ memmove(p + shift, p, len + 1);
memset(p, ' ', shift);
}
gui->status_lines[j] = p;
@@ -1888,13 +1888,13 @@ int gui_notify_call(struct osmocom_ms *ms)
/* if only one call */
if (calls == 1) {
/* insert space above call state */
- memcpy(gui->status_lines + 1, gui->status_lines,
+ memmove(gui->status_lines + 1, gui->status_lines,
j * sizeof(char *));
gui->status_lines[0] = "";
j++;
if (j > 2) {
/* insert space below call state */
- memcpy(gui->status_lines + 3, gui->status_lines + 2,
+ memmove(gui->status_lines + 3, gui->status_lines + 2,
(j - 2) * sizeof(char *));
gui->status_lines[2] = "";
j++;
diff --git a/src/host/layer23/src/ui/ui.c b/src/host/layer23/src/ui/ui.c
index fbed986..b5d0100 100644
--- a/src/host/layer23/src/ui/ui.c
+++ b/src/host/layer23/src/ui/ui.c
@@ -37,7 +37,7 @@ static char *ui_center(const char *text)
len = strlen(line);
if (len + 1 < UI_COLS) {
shift = (UI_COLS - len) / 2;
- memcpy(line + shift, line, len + 1);
+ memmove(line + shift, line, len + 1);
memset(line, ' ', shift);
}
@@ -146,7 +146,7 @@ static int bottom_puts(struct ui_inst *ui, const char *text)
if ((p = strchr(bottom_line, ' '))
&& (space = UI_COLS - strlen(bottom_line))) {
p++;
- memcpy(p + space, p, strlen(p));
+ memmove(p + space, p, strlen(p));
memset(p, ' ', space);
}
@@ -410,7 +410,7 @@ static int keypad_stringview(struct ui_inst *ui, struct ui_view *uv,
ud->stringview.number[ud->stringview.pos] = '\0';
} else {
/* insert digit */
- memcpy(ud->stringview.number + ud->stringview.pos + 1,
+ memmove(ud->stringview.number + ud->stringview.pos + 1,
ud->stringview.number + ud->stringview.pos,
strlen(ud->stringview.number +
ud->stringview.pos)
@@ -447,7 +447,7 @@ static int keypad_stringview(struct ui_inst *ui, struct ui_view *uv,
ud->stringview.number[ud->stringview.pos] = '\0';
} else {
/* remove digit */
- memcpy(ud->stringview.number + ud->stringview.pos - 1,
+ memmove(ud->stringview.number + ud->stringview.pos - 1,
ud->stringview.number + ud->stringview.pos,
strlen(ud->stringview.number +
ud->stringview.pos)