Blame SOURCES/100-fix-double-free-hasher.patch

db5b59
--- libkcapi-1.2.0/apps/kcapi-hasher.c.fix-double-free-hasher	2020-05-26 16:31:28.296332614 +0200
db5b59
+++ libkcapi-1.2.0/apps/kcapi-hasher.c	2020-05-26 16:37:07.681011437 +0200
db5b59
@@ -301,7 +301,7 @@ static int hasher(struct kcapi_handle *h
db5b59
 				fprintf(stderr,
db5b59
 					"Use of mmap failed mapping %zu bytes at offset %" PRId64 " of file %s (%d)\n",
db5b59
 					mapped, (int64_t)offset, filename, ret);
db5b59
-				goto out;
db5b59
+				return ret;
db5b59
 			}
db5b59
 			/* Compute hash */
db5b59
 			memblock_p = memblock;
db5b59
@@ -311,8 +311,10 @@ static int hasher(struct kcapi_handle *h
db5b59
 						 INT_MAX : (uint32_t)left;
db5b59
 
db5b59
 				ret = kcapi_md_update(handle, memblock_p, todo);
db5b59
-				if (ret < 0)
db5b59
-					goto out;
db5b59
+				if (ret < 0) {
db5b59
+			        munmap(memblock, mapped);
db5b59
+					return ret;
db5b59
+                }
db5b59
 				left -= todo;
db5b59
 				memblock_p += todo;
db5b59
 			} while (left);
db5b59
@@ -329,7 +331,7 @@ static int hasher(struct kcapi_handle *h
db5b59
 
db5b59
 			ret = kcapi_md_update(handle, tmpbuf, bufsize);
db5b59
 			if (ret < 0)
db5b59
-				goto out;
db5b59
+				return ret;
db5b59
 		}
db5b59
 		kcapi_memset_secure(tmpbuf, 0, sizeof(tmpbuf));
db5b59
 	}
db5b59
@@ -340,7 +342,7 @@ static int hasher(struct kcapi_handle *h
db5b59
 		if (hashlen > (uint32_t)ret) {
db5b59
 			fprintf(stderr, "Invalid truncated hash size: %lu > %i\n",
db5b59
 			        (unsigned long)hashlen, ret);
db5b59
-			goto out;
db5b59
+			return ret;
db5b59
 		}
db5b59
 
db5b59
 		if (!hashlen)
db5b59
@@ -376,11 +378,6 @@ static int hasher(struct kcapi_handle *h
db5b59
 		fprintf(stderr, "Generation of hash for file %s failed (%d)\n",
db5b59
 			filename ? filename : "stdin", ret);
db5b59
 	}
db5b59
-
db5b59
-out:
db5b59
-	if (memblock)
db5b59
-		munmap(memblock, mapped);
db5b59
-
db5b59
 	return ret;
db5b59
 }
db5b59