aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--field.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4311db1d..a589fb33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-12-18 Paul Eggert <eggert@Penguin.CS.UCLA.EDU>
+
+ Fix memcpy issue found by -fsanitize=undefined
+ * field.c (set_record): Don't memcpy (databuf, NULL, 0),
+ as the C standard says the resulting behavior is undefined.
+
2019-12-16 Arnold D. Robbins <arnold@skeeve.com>
* awkgram.y, command.y: Upgrade to Bison 3.5.
diff --git a/field.c b/field.c
index 8c7fe18e..28891c85 100644
--- a/field.c
+++ b/field.c
@@ -288,7 +288,9 @@ set_record(const char *buf, int cnt, const awk_fieldwidth_info_t *fw)
memset(databuf, '\0', databuf_size);
}
/* copy the data */
- memcpy(databuf, buf, cnt);
+ if (cnt != 0) {
+ memcpy(databuf, buf, cnt);
+ }
/*
* Add terminating '\0' so that C library routines