Repository: incubator-hawq Updated Branches: refs/heads/master 3ba7d8ef4 -> 5323b5b90
HAWQ-893. Only copy and index status_str_length Previously status_str was being indexed with a value that overflowed its expected length and would zero-out the string 'test' Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/5323b5b9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/5323b5b9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/5323b5b9 Branch: refs/heads/master Commit: 5323b5b90d077579134a5254d822a54fbc2093bd Parents: 3ba7d8e Author: Kavinder Dhaliwal <[email protected]> Authored: Tue Jul 5 19:00:26 2016 -0700 Committer: yaoj2 <[email protected]> Committed: Wed Jul 6 10:31:27 2016 +0800 ---------------------------------------------------------------------- src/test/regress/pg_regress.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/5323b5b9/src/test/regress/pg_regress.c ---------------------------------------------------------------------- diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index ffe2161..42b607c 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -602,11 +602,12 @@ load_expected_statuses(char *filename) strncpy(test, buf, sep_index); test[sep_index+1] = '\0'; - char status_str[strlen(buf)-sep_index]; + int status_str_length = strlen(buf)-sep_index; + char status_str[status_str_length]; memset(status_str, 0, sizeof(status_str)); - strncpy(status_str, buf + sep_index +1, strlen(buf)); - status_str[sep_index+1] = '\0'; + strncpy(status_str, buf + sep_index +1, status_str_length); + status_str[status_str_length] = '\0'; line_valid = (sscanf(status_str, "%d", (int *) (&status)) == 1);
