Commit Diff


commit - 2633cf30b7cd97910764fc4c016df7959858171d
commit + b15057701186a99af7523319371ec7e0db9dd195
blob - bfe6f67b6065aabb9a1a27b1531267cc64064f47
blob + c2033cbd85a6b278e2b0b27aa0f57ec1f4d0c115
--- lib/privsep.c
+++ lib/privsep.c
@@ -139,11 +139,6 @@ got_privsep_recv_imsg(struct imsg *imsg, struct imsgbu
 		n = imsg_get(ibuf, imsg);
 		if (n == -1)
 			return got_error_from_errno("imsg_get");
-	}
-
-	if (imsg->hdr.len < IMSG_HEADER_SIZE + min_datalen) {
-		imsg_free(imsg);
-		return got_error(GOT_ERR_PRIVSEP_LEN);
 	}
 
 	if (imsg->hdr.type == GOT_IMSG_ERROR) {
@@ -153,6 +148,11 @@ got_privsep_recv_imsg(struct imsg *imsg, struct imsgbu
 		return err;
 	}
 
+	if (imsg->hdr.len < IMSG_HEADER_SIZE + min_datalen) {
+		imsg_free(imsg);
+		return got_error(GOT_ERR_PRIVSEP_LEN);
+	}
+
 	return NULL;
 }