imc-os: Terminate buffer after fread(3) call to make Coverity happy
authorTobias Brunner <tobias@strongswan.org>
Fri, 11 Mar 2016 13:40:55 +0000 (14:40 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 11 Mar 2016 14:23:18 +0000 (15:23 +0100)
src/libimcv/imc/imc_os_info.c

index 7f2135e..55e152a 100644 (file)
@@ -435,13 +435,13 @@ static bool extract_platform_info(os_type_t *type, chunk_t *name,
                }
                len = min(file_len, len);
                rewind(file);
-               buf[len] = '\0';
                if (fread(buf, 1, len, file) != len)
                {
                        DBG1(DBG_IMC, "failed to read file \"%s\"", releases[i]);
                        fclose(file);
                        return FALSE;
                }
+               buf[len] = '\0';
                fclose(file);
 
                DBG1(DBG_IMC, "processing \"%s\" file", releases[i]);