Download raw body.
got send: "raw object has unexpected size" for any blob of 16334..16341 bytes (got 0.131)
got send: "raw object has unexpected size" for any blob of 16334..16341 bytes (got 0.131)
On Mon, Nov 23, 2026 at 11:33:37PM +0100, Daniil Ryvkin wrote:
> Hello,
>
> OpenBSD-current, amd64:
> gotadmin pack and got send fail with
> "raw object has unexpected size" if the repository contains a blob of
> 16334..16341 bytes (any content; 16333 and 16342 work).
>
> Reproducer:
> mkdir /tmp/gotr
> cd /tmp/gotr
> mkdir a
> head -c 16335 /dev/zero > a/file
> got init -b main r.git && got import -r r.git -m "init" a
> gotadmin pack -r r.git refs/heads/main
>
> Thanks.
Thank you Daniil! This fixes the issue:
fix privsep-reading of raw objects within a certain size range
The privsep layer made inconsistent decisions about sending raw object
data inline vs. writing the data to a file. This made files in the size
range of 16334..16341 bytes trigger errors when packing a repository.
Problem reported by Daniil Ryvkin with a small reproducer.
Regression test and fix by me.
M lib/privsep.c | 3+ 1-
M libexec/got-read-object/got-read-object.c | 1+ 1-
M regress/cmdline/pack.sh | 64+ 0-
3 files changed, 68 insertions(+), 2 deletions(-)
commit - 8fdee7bf59a9dd9448ca69b333c468f8c8a7b7081a59bc04fefc0860e9fd655e
commit + c40609337cb765cfa614a904ec6977972932c083dc85090f4734941750bf8d49
blob - 1da9367a400df47360b6316deba363fa4b3c49346f35dc39ba465111cd4bf694
blob + d141247f57bb96d0795d177deb932c93e54983a8a8961e8ccf287a5960e80323
--- lib/privsep.c
+++ lib/privsep.c
@@ -298,7 +298,9 @@ got_privsep_send_raw_obj(struct imsgbuf *ibuf, off_t s
if (imsg_add(wbuf, &iobj, sizeof(iobj)) == -1)
return got_error_from_errno("imsg_add RAW_OBJECT");
- if (data && size + hdrlen <= GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX) {
+ if (data) {
+ if (size + hdrlen > GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX)
+ return got_error(GOT_ERR_PRIVSEP_LEN);
if (imsg_add(wbuf, data, size + hdrlen) == -1)
return got_error_from_errno("imsg_add RAW_OBJECT");
}
blob - 01fbc7ea298392445021c3f2e4e90c9b6784fbffabbd01160a57a2f255e6c09f
blob + 04952148fbaa49270a6c0072af2101868ed4ffcc6df21b2184c6f3061e6ded69
--- libexec/got-read-object/got-read-object.c
+++ libexec/got-read-object/got-read-object.c
@@ -76,7 +76,7 @@ send_raw_obj(struct imsgbuf *ibuf, struct got_object *
}
err = got_object_read_raw(&data, &size, &hdrlen,
- GOT_PRIVSEP_INLINE_BLOB_DATA_MAX, outfd, expected_id, fd);
+ GOT_PRIVSEP_INLINE_OBJECT_DATA_MAX, outfd, expected_id, fd);
if (err)
goto done;
blob - a23390e3103042db7da9294edc879ee1ac29a96016c980afafd66250415403c8
blob + 0879a5d0a915bf06744302e01270a6212575f95df4fbd6c89a3d822686d50b64
--- regress/cmdline/pack.sh
+++ regress/cmdline/pack.sh
@@ -857,6 +857,69 @@ test_pack_exclude_via_ancestor_commit_packed() {
test_done "$testroot" "$ret"
}
+
+test_pack_large_loose_object() {
+ local testroot=`test_init pack_all_loose_objects`
+
+ # no pack files should exist yet
+ ls $testroot/repo/.git/objects/pack/ > $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+ echo -n > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ dd if=/dev/zero of=$testroot/wt/large-file count=16335 bs=1 \
+ > /dev/null 2>/dev/null
+ (cd $testroot/wt && got add large-file > /dev/null)
+ (cd $testroot/wt && got commit -m "adding a large file" > /dev/null)
+
+ gotadmin pack -r $testroot/repo > $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ echo "gotadmin pack failed unexpectedly" >&2
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+ packname=`grep ^Wrote $testroot/stdout | cut -d ' ' -f2`
+ gotadmin listpack $testroot/repo/.git/objects/pack/pack-$packname \
+ > $testroot/stdout
+
+ for d in $testroot/repo/.git/objects/[0-9a-f][0-9a-f]; do
+ id0=`basename $d`
+ ret=0
+ for e in `ls $d`; do
+ obj_id=${id0}${e}
+ if grep -q ^$obj_id $testroot/stdout; then
+ continue
+ fi
+ echo "loose object $obj_id was not packed" >&2
+ ret=1
+ break
+ done
+ if [ $ret -eq 1 ]; then
+ break
+ fi
+ done
+
+ test_done "$testroot" "$ret"
+}
+
test_parseargs "$@"
run_test test_pack_all_loose_objects
run_test test_pack_exclude
@@ -869,3 +932,4 @@ run_test test_pack_bad_ref
run_test test_pack_tagged_tag
run_test test_pack_exclude_via_ancestor_commit
run_test test_pack_exclude_via_ancestor_commit_packed
+run_test test_pack_large_loose_object
got send: "raw object has unexpected size" for any blob of 16334..16341 bytes (got 0.131)
got send: "raw object has unexpected size" for any blob of 16334..16341 bytes (got 0.131)