From de8331eeaf1b2a7f9dbbe7347ec0a3a88ad455fd Mon Sep 17 00:00:00 2001 From: Jack May Date: Thu, 30 Sep 2021 19:47:26 -0700 Subject: [PATCH] Deploy error is buffer is too small (#20358) * Deploy error is buffer is too small * missing file --- cli/src/program.rs | 8 +- cli/tests/fixtures/build.sh | 1 + cli/tests/fixtures/noop.so | Bin 1592 -> 1592 bytes cli/tests/fixtures/noop_large.so | Bin 0 -> 4776 bytes cli/tests/program.rs | 196 ++++++++++++++++++------------- 5 files changed, 124 insertions(+), 81 deletions(-) create mode 100644 cli/tests/fixtures/noop_large.so diff --git a/cli/src/program.rs b/cli/src/program.rs index 7333687256..a6d72bd3a1 100644 --- a/cli/src/program.rs +++ b/cli/src/program.rs @@ -2026,7 +2026,13 @@ fn complete_partial_program_init( return Err("Buffer account is already executable".into()); } if account.owner != *loader_id && !system_program::check_id(&account.owner) { - return Err("Buffer account is already owned by another account".into()); + return Err("Buffer account passed is already in use by another program".into()); + } + if !account.data.is_empty() && account.data.len() < account_data_len { + return Err( + "Buffer account passed is not large enough, may have been for a different deploy?" + .into(), + ); } if account.data.is_empty() && system_program::check_id(&account.owner) { diff --git a/cli/tests/fixtures/build.sh b/cli/tests/fixtures/build.sh index 0647e54140..128297b0d8 100755 --- a/cli/tests/fixtures/build.sh +++ b/cli/tests/fixtures/build.sh @@ -5,3 +5,4 @@ cd "$(dirname "$0")" make -C ../../../programs/bpf/c/ cp ../../../programs/bpf/c/out/noop.so . +cat noop.so noop.so noop.so > noop_large.so diff --git a/cli/tests/fixtures/noop.so b/cli/tests/fixtures/noop.so index 502681cf6e5f1b97b72def214afaaf144a2d1fb4..3f95eeac05615f5108cd77c27d2234585111ea8b 100755 GIT binary patch delta 57 zcmdnNvx8?t43nn0iMffXNs>Wgs;Q}2N}{2WL6T)+ilLc_X`-QVs)7)KP)aVzb;owqZd+1bp)Jx+66sK>ZJih` zLW5|Vs+8g9Dy<~CS)Tf;)3f+Vc_3Z0M22CR`-%FQ#Sd1EfR|MM*C6h%Q}%4V1$7`i z`W+r;G;rbGe>r_6@kCWnn;Q)g_mnjKlBFpBz4gKE3G z?m>yB65?R*^^2Y7Pah$uzd%{Gp)G~@};wRDnCqHFhy&tLf!#vhYO1bgHKFt2*p zUf3&5H+Ud92z%ra5Po2fd;{KQTe(tTk30q