From 76d90617cc1cd90014a9468dde599de31dfca0b4 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Fri, 6 Dec 2019 12:34:57 +0100 Subject: [PATCH] build: avoid three compiler warnings when using gcc-9.2 or newer This addresses https://savannah.gnu.org/bugs/?57360. Reported-by: Brand Huntsman --- src/files.c | 2 +- src/nano.c | 2 +- src/text.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/files.c b/src/files.c index 7032abc5..df79c5c3 100644 --- a/src/files.c +++ b/src/files.c @@ -244,7 +244,7 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi lockdata[27] = mypid / (256 * 256 * 256); snprintf(&lockdata[2], 11, "nano %s", VERSION); strncpy(&lockdata[28], mypwuid->pw_name, 16); - strncpy(&lockdata[68], myhostname, 31); + strncpy(&lockdata[68], myhostname, 32); if (origfilename != NULL) strncpy(&lockdata[108], origfilename, 768); if (modified == TRUE) diff --git a/src/nano.c b/src/nano.c index 734a528e..25a070b4 100644 --- a/src/nano.c +++ b/src/nano.c @@ -255,7 +255,7 @@ void unpartition_buffer(void) strlen(antedata) + strlen(openfile->filetop->data) + 1); memmove(openfile->filetop->data + strlen(antedata), openfile->filetop->data, strlen(openfile->filetop->data) + 1); - strncpy(openfile->filetop->data, antedata, strlen(antedata)); + memcpy(openfile->filetop->data, antedata, strlen(antedata)); free(antedata); antedata = NULL; diff --git a/src/text.c b/src/text.c index 011633c4..53867c8b 100644 --- a/src/text.c +++ b/src/text.c @@ -102,7 +102,7 @@ void indent_a_line(linestruct *line, char *indentation) /* Add the fabricated indentation to the beginning of the line. */ line->data = charealloc(line->data, length + indent_len + 1); memmove(line->data + indent_len, line->data, length + 1); - strncpy(line->data, indentation, indent_len); + memcpy(line->data, indentation, indent_len); openfile->totsize += indent_len;