summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-11-29 13:18:38 +0100
committerTobias Hunger <tobias.hunger@qt.io>2016-12-06 10:18:10 +0000
commit5a58e96237f046744c604c59f3c33cfd06fc6bd1 (patch)
treeb704ade0ef9dbcd1f6fcafb0116e869229eb15d4 /src
parent8b48f47d129db4d590446c10f71dd49d038c0379 (diff)
downloadqt-creator-5a58e96237f046744c604c59f3c33cfd06fc6bd1.tar.gz
Process_stub: Make sure strings are \0 terminated
Change-Id: Ic3d431e850cb09627359aae0e0c755f02b4835c0 Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/utils/process_stub_unix.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libs/utils/process_stub_unix.c b/src/libs/utils/process_stub_unix.c
index 145d31d50d..302f8212a0 100644
--- a/src/libs/utils/process_stub_unix.c
+++ b/src/libs/utils/process_stub_unix.c
@@ -224,11 +224,12 @@ int main(int argc, char *argv[])
fseek(envFd, 0, SEEK_END);
size = ftell(envFd);
rewind(envFd);
- envdata = malloc(size);
+ envdata = malloc(size + 1);
if (fread(envdata, 1, size, envFd) != (size_t)size) {
perror("Failed to read env file");
doExit(1);
}
+ envdata[size] = '\0';
fclose(envFd);
for (count = 0, edp = envdata; edp < envdata + size; ++count)
edp += strlen(edp) + 1;