"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
delta.c overrides errors in some cases
To:
gameoftrees@openbsd.org
Date:
Mon, 21 Jul 2025 15:30:03 +0200

Download raw body.

Thread
  • Stefan Sperling:

    delta.c overrides errors in some cases

Avoid clobbering earlier errors in got_delta_apply and got_delta_apply_in_mem.
We want to see the first thing that went wrong, not unrelated problems
flagged while an error is being returned.

These functions should probably be using the 'goto done' idiom. But
rewriting them to use that idiom would result in a more complicated diff.

ok?

M  lib/delta.c  |  3+  3-

1 file changed, 3 insertions(+), 3 deletions(-)

commit - 529f16d393fbab504621b40449967a0a33f4041c
commit + 52182470b7df7e8e4e7215741242644fc79d84c4
blob - 2c3f8c2ebcd41b76c90f5701a0b1ffc43fbdccc3
blob + d101d183c5835c655baa20b5ca59d7a24025c0be
--- lib/delta.c
+++ lib/delta.c
@@ -320,7 +320,7 @@ got_delta_apply_in_mem(uint8_t *base_buf, size_t base_
 		}
 	}
 
-	if (*outsize != result_size)
+	if (err == NULL && *outsize != result_size)
 		err = got_error_msg(GOT_ERR_BAD_DELTA,
 		    "delta application result size mismatch");
 	return err;
@@ -387,12 +387,12 @@ got_delta_apply(FILE *base_file, const uint8_t *delta_
 		}
 	}
 
-	if (*outsize != result_size)
+	if (err == NULL && *outsize != result_size)
 		err = got_error_msg(GOT_ERR_BAD_DELTA,
 		    "delta application result size mismatch");
 
 	if (memstream != NULL) {
-		if (fclose(memstream) == EOF)
+		if (fclose(memstream) == EOF && err == NULL)
 			err = got_error_from_errno("fclose");
 		if (err == NULL) {
 			size_t n;