1
0
Fork 0
forked from soccera/rdo

Remove debug printf & use strlen() at write

In sessions.h, now line 95, we used sizeof(ts_str) to
determine how much to write, but as ts_str can be longer
than the actual string written, it wrote random data
after the actual timestamp.
This commit is contained in:
sw1tchbl4d3 2021-07-16 00:12:12 +02:00
parent 24638bc999
commit c80be89ef9

View file

@ -92,7 +92,7 @@ void setsession(int pid, unsigned int ts_ttl) {
snprintf(ts_str, sizeof(ts_str), "%llu", (unsigned long long)time(NULL));
if (write(fd, ts_str, sizeof(ts_str)) < 0)
if (write(fd, ts_str, strlen(ts_str)) < 0)
err(1, "Could not write to %s", path);
close(fd);
@ -123,7 +123,6 @@ int getsession(int pid, unsigned int ts_ttl) {
err(1, "Could not open %s", path);
}
printf("%d", fd);
if (read(fd, ts_str, sizeof(ts_str)) < 0)
err(1, "Could not read %s", path);