From 6d6086267cf59f9a1f853a51e46c0fd56f94eb7c Mon Sep 17 00:00:00 2001 From: Roland Schulz Date: Tue, 27 Jan 2015 02:04:39 -0500 Subject: [PATCH] Fix unitlized memory read in checkpoint Older versions didn't prefix the version string with VERSION and thus the scanf isn't returning two fields for those. Change-Id: I0c8734bd18a62ca5fd6841f2c57fa5a9698bc88c --- src/gromacs/gmxlib/checkpoint.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gromacs/gmxlib/checkpoint.cpp b/src/gromacs/gmxlib/checkpoint.cpp index 438eafba7d..f53a55d2ae 100644 --- a/src/gromacs/gmxlib/checkpoint.cpp +++ b/src/gromacs/gmxlib/checkpoint.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2008,2009,2010,2011,2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2008,2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -1759,8 +1759,9 @@ static void check_match(FILE *fplog, int gmx_major, gmx_minor; int cpt_major, cpt_minor; sscanf(gmx_version(), "VERSION %5d.%5d", &gmx_major, &gmx_minor); - sscanf(version, "VERSION %5d.%5d", &cpt_major, &cpt_minor); - version_differs = (gmx_major != cpt_major || gmx_minor != cpt_minor); + int ret = sscanf(version, "VERSION %5d.%5d", &cpt_major, &cpt_minor); + version_differs = (ret < 2 || gmx_major != cpt_major || + gmx_minor != cpt_minor); } check_string(fplog, "Build time", BUILD_TIME, btime, &mm); -- 2.22.0