In get_string(), 0-terminate the contents of buf ``just in case'';
otherwise, if the very first fgetc() already yielded EOF, the returned string won't get terminated at all. MFC after: 1 day
This commit is contained in:
parent
7ae71655e7
commit
8a2ecea916
@ -124,6 +124,7 @@ get_string(int procfd, void *offset, int max) {
|
||||
err(1, "fdopen");
|
||||
buf = malloc( size = (max ? max : 64 ) );
|
||||
len = 0;
|
||||
buf[0] = 0;
|
||||
fseek(p, (long)offset, SEEK_SET);
|
||||
while ((c = fgetc(p)) != EOF) {
|
||||
buf[len++] = c;
|
||||
|
Loading…
Reference in New Issue
Block a user