From 10411cd9c6fc564485c7099874864283a40b10d2 Mon Sep 17 00:00:00 2001
From: David Timber <mieabby@gmail.com>
Date: Sat, 14 Aug 2021 01:37:00 +1000
Subject: Fix bne ...

* Wrong args to prne_start_bin_rcb_compat() made ba with 1 missing arch
  (that of parent) in the next generation of exec. Blame
  eea0a9fbbf1aff1eac1f17914d5c116de98e1d93
* proone-pack: add os string to suffix of output files
---
 src/bne.c         | 2 +-
 src/pack.c        | 2 +-
 src/proone-pack.c | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

(limited to 'src')

diff --git a/src/bne.c b/src/bne.c
index a0f64d3..41022e0 100644
--- a/src/bne.c
+++ b/src/bne.c
@@ -1389,7 +1389,7 @@ static bool bne_sh_start_rcb (prne_bne_t *ctx, bne_sh_ctx_t *sh_ctx) {
 	ctx->result.prc = prne_start_bin_rcb_compat(
 		&sh_ctx->rcb,
 		ctx->result.bin_host,
-		NULL,
+		ctx->param.rcb->self,
 		ctx->param.rcb->m_self,
 		ctx->param.rcb->self_len,
 		ctx->param.rcb->exec_len,
diff --git a/src/pack.c b/src/pack.c
index b1e6a36..fa0d19c 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -309,7 +309,7 @@ static ssize_t pack_rcb_dvread_f (
 			nb_bin_loc = ctx->buf + ctx->buf_len + 6;
 			ctx->buf_len += 8;
 
-			if (ctx->self.arch != PRNE_ARCH_NONE) {
+			if (prne_bin_host_inrange(&ctx->self)) {
 				ctx->buf[ctx->buf_len + 0] = 0;
 				ctx->buf[ctx->buf_len + 1] = 0;
 				ctx->buf[ctx->buf_len + 2] = (uint8_t)ctx->self.os;
diff --git a/src/proone-pack.c b/src/proone-pack.c
index ad2a75c..0078413 100644
--- a/src/proone-pack.c
+++ b/src/proone-pack.c
@@ -265,9 +265,11 @@ static bool do_rcb (const char *prefix) {
 
 		prne_free(out_path);
 		out_path = prne_alloc_str(
-			prefix_len + 1 + strlen(arch_str));
+			prefix_len + 1 + strlen(os_str) + 1 + strlen(arch_str));
 		strcpy(out_path, prefix);
 		strcat(out_path, ".");
+		strcat(out_path, os_str);
+		strcat(out_path, ".");
 		strcat(out_path, arch_str);
 
 		fd = open(out_path, O_WRONLY | O_CREAT | O_TRUNC, 0755);
-- 
cgit v1.2.3-70-g09d2