[OpenWrt-Devel] [PATCH] mtd: fix md5sum error checking

Zefir Kurtisi zefir.kurtisi at neratec.com
Thu Mar 5 11:04:54 EST 2015


In mtd_verify(), the return value of md5sum() has been
interpreted as error if nonzero, while the function
returns number of processed bytes, which caused
mtd_verify() to always fail.

This patch fixes error checking to interpret only
negative values as errors.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi at neratec.com>
---
 package/system/mtd/src/mtd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c
index 72b9ddf..741b57b 100644
--- a/package/system/mtd/src/mtd.c
+++ b/package/system/mtd/src/mtd.c
@@ -337,7 +337,7 @@ mtd_verify(const char *mtd, char *file)
 	if (quiet < 2)
 		fprintf(stderr, "Verifying %s against %s ...\n", mtd, file);
 
-	if (stat(file, &s) || md5sum(file, f_md5)) {
+	if (stat(file, &s) || md5sum(file, f_md5) < 0) {
 		fprintf(stderr, "Failed to hash %s\n", file);
 		return -1;
 	}
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list