diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-06-16 14:58:11 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-06-16 14:58:11 -0400 |
commit | 6b74f5eaadc4489e08a23686f99f096ad0e08936 (patch) | |
tree | b312caa43cb101f10fa2a4e4bb2950c9cbc8f142 /src/interfaces/ecpg/ecpglib/descriptor.c | |
parent | 5d923eb29bb643e311680bab329363d8a9a9768a (diff) | |
download | postgresql-6b74f5eaadc4489e08a23686f99f096ad0e08936.tar.gz postgresql-6b74f5eaadc4489e08a23686f99f096ad0e08936.zip |
Avoid unnecessary use of strncpy in a couple of places in ecpg.
Use of strncpy with a length limit based on the source, rather than
the destination, is non-idiomatic and draws warnings from gcc 8.
Replace with memcpy, which does exactly the same thing in these cases,
but with less chance for confusion.
Backpatch to all supported branches.
Discussion: https://postgr.es/m/21789.1529170195@sss.pgh.pa.us
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/descriptor.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/descriptor.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/interfaces/ecpg/ecpglib/descriptor.c b/src/interfaces/ecpg/ecpglib/descriptor.c index f38bf343f0b..8fdf5606c09 100644 --- a/src/interfaces/ecpg/ecpglib/descriptor.c +++ b/src/interfaces/ecpg/ecpglib/descriptor.c @@ -218,7 +218,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va (struct ECPGgeneric_varchar *) var; if (varcharsize == 0) - strncpy(variable->arr, value, strlen(value)); + memcpy(variable->arr, value, strlen(value)); else strncpy(variable->arr, value, varcharsize); |