diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2019-05-15 17:04:16 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2019-05-15 17:04:16 +0200 |
commit | 8bc6aa9880d3d9a37672d511d517b36609dab028 (patch) | |
tree | 2dc1c88f45635fed723a0df900c16a9c0d3d2ff5 /gatchat | |
parent | dff595671bf5a46f7c9231966a6cd7d2a0183076 (diff) | |
download | ofono-8bc6aa9880d3d9a37672d511d517b36609dab028.tar.gz |
gatchat: Avoid string overflow warning in debug function
Diffstat (limited to 'gatchat')
-rw-r--r-- | gatchat/gatutil.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gatchat/gatutil.c b/gatchat/gatutil.c index a2528e13..ea433bcb 100644 --- a/gatchat/gatutil.c +++ b/gatchat/gatutil.c @@ -67,8 +67,7 @@ void g_at_util_debug_chat(gboolean in, const char *str, gsize len, escaped_str[0] = type; escaped_str[1] = ' '; - escaped_str[2] = '\0'; - escaped_str[escaped] = '\0'; + memset(escaped_str + 2, '\0', escaped - 2); for (escaped = 2, i = 0; i < len; i++) { unsigned char c = str[i]; @@ -87,11 +86,11 @@ void g_at_util_debug_chat(gboolean in, const char *str, gsize len, escaped_str[escaped++] = 'n'; break; case 26: - strncpy(&escaped_str[escaped], ctrlz, ctrlz_size); + memcpy(escaped_str + escaped, ctrlz, ctrlz_size); escaped += ctrlz_size; break; case 25: - strncpy(&escaped_str[escaped], esc, esc_size); + memcpy(escaped_str + escaped, esc, esc_size); escaped += esc_size; break; default: |