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>
This commit is contained in:
Tobias Hunger
2016-11-29 13:18:38 +01:00
parent 8b48f47d12
commit 5a58e96237

View File

@@ -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;