Commit 626ad11b by Christian Seiler Committed by Serge Hallyn

apparmor/attach: make sure buffer is NUL-terminated

parent a0e93eeb
...@@ -42,12 +42,13 @@ again: ...@@ -42,12 +42,13 @@ again:
} }
sz += 1024; sz += 1024;
buf = realloc(buf, sz); buf = realloc(buf, sz);
memset(buf, 0, sz);
if (!buf) { if (!buf) {
ERROR("out of memory"); ERROR("out of memory");
fclose(f); fclose(f);
return NULL; return NULL;
} }
ret = fread(buf, 1, sz, f); ret = fread(buf, 1, sz - 1, f);
fclose(f); fclose(f);
if (ret >= sz) if (ret >= sz)
goto again; goto again;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment