Greetings, everyone! While analyzing output of Svace static analyzer [1] I've found a bug.
In function intoasc(interval * i, char *str) from file src/interfaces/ecpg/compatlib/informix.c we return a non-terminated string since we use memcpy on tmp which is itself NULL-teminated but
last zero byte is not copied.The proposed solution is to use strcpy instead, since it is used in all other functions in informix.c.
The patch is attached. [1] - https://svace.pages.ispras.ru/svace-website/en/ Oleg Tselebrovskiy, Postgres Pro
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index dccf39582da..80d40aa3e09 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -654,7 +654,7 @@ intoasc(interval * i, char *str) if (!tmp) return -errno; - memcpy(str, tmp, strlen(tmp)); + strcpy(str, tmp); free(tmp); return 0; }