forked from soccera/rdo
Null-terminate read data
This commit is contained in:
parent
e1147f4c7c
commit
a23bb67985
1 changed files with 7 additions and 1 deletions
|
@ -18,6 +18,10 @@ int getpstartts(int pid, unsigned long long* startts) {
|
|||
err(1, "Could not open %s", path);
|
||||
|
||||
int bytes_read = read(fd, fc, sizeof(fc));
|
||||
if (bytes_read < 0)
|
||||
err(1, "Could not read %s", path);
|
||||
fc[bytes_read] = '\0';
|
||||
|
||||
close(fd);
|
||||
|
||||
if (memchr(ptr, '\0', bytes_read) != NULL)
|
||||
|
@ -123,8 +127,10 @@ int getsession(int pid, unsigned int ts_ttl) {
|
|||
err(1, "Could not open %s", path);
|
||||
}
|
||||
|
||||
if (read(fd, ts_str, sizeof(ts_str)) < 0)
|
||||
int bytes_read = read(fd, ts_str, sizeof(ts_str));
|
||||
if (bytes_read < 0)
|
||||
err(1, "Could not read %s", path);
|
||||
ts_str[bytes_read] = '\0';
|
||||
|
||||
startts = strtoull(ts_str, NULL, 10);
|
||||
current = time(NULL);
|
||||
|
|
Loading…
Add table
Reference in a new issue