mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
fnread(): make sure to NUL terminate buffer
Note, this is dead code, currently unsused in Finit. Possibly an external plugin makes use of it, but even that is highly unlikely. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
c8d6ad6546
commit
2f34315634
1 file changed
+3
-2
+3
-2
@@ -177,7 +177,8 @@ int fnread(char *buf, size_t len, char *fmt, ...)
|
|||||||
if (!fp)
|
if (!fp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
len = fread(buf, sizeof(char), len, fp);
|
len = fread(buf, sizeof(char), len - 1, fp);
|
||||||
|
buf[len] = 0;
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return (int)len;
|
return (int)len;
|
||||||
@@ -216,7 +217,7 @@ int fnwrite(char *value, char *fmt, ...)
|
|||||||
|
|
||||||
int fngetint(char *path, int *val)
|
int fngetint(char *path, int *val)
|
||||||
{
|
{
|
||||||
char buf[10];
|
char buf[64];
|
||||||
|
|
||||||
if (fnread(buf, sizeof(buf), path) <= 0)
|
if (fnread(buf, sizeof(buf), path) <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in new issue
Block a user