mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
ecpg: Fix off-by-one error in memory copying
In a rare case, one byte past the end of memory belonging to the sqlca_t structure would be written to. found by Coverity
This commit is contained in:
@ -525,7 +525,7 @@ ECPGset_var(int number, void *pointer, int lineno)
|
|||||||
struct sqlca_t *sqlca = ECPGget_sqlca();
|
struct sqlca_t *sqlca = ECPGget_sqlca();
|
||||||
|
|
||||||
sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
|
sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
|
||||||
strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
|
strncpy(sqlca->sqlstate, "YE001", sizeof(sqlca->sqlstate));
|
||||||
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
|
snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
|
||||||
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
|
sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
|
||||||
/* free all memory we have allocated for the user */
|
/* free all memory we have allocated for the user */
|
||||||
|
Reference in New Issue
Block a user