Nature of the problem was not initialised buffer[256] on special condition
there were probability that program will work on unitialised data that
could provide unexpected program behaviour.

Adding additional transparent I/O buffer for I/O operations
improve reading on heavyloaded enviroments with NFS.

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod at intel.com>
---
 lib/librte_cfgfile/rte_cfgfile.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c
index b81c273..88fcb46 100644
--- a/lib/librte_cfgfile/rte_cfgfile.c
+++ b/lib/librte_cfgfile/rte_cfgfile.c
@@ -93,10 +93,14 @@ rte_cfgfile_load(const char *filename, int flags)
        int curr_section = -1;
        int curr_entry = -1;
        char buffer[256];
+       char f_streambuff[BUFSIZ];
        int lineno = 0;
        struct rte_cfgfile *cfg = NULL;
+       memset(buffer, '\0', 256*sizeof(char));
+       memset(f_streambuff, '\0', BUFSIZ);

        FILE *f = fopen(filename, "r");
+       setbuf(f, f_streambuff);
        if (f == NULL)
                return NULL;

-- 
2.1.0

Reply via email to