From: Omar Polo Subject: fix overzelous sanity check in got_privsep_get_imsg_obj To: gameoftrees@openbsd.org Date: Sat, 18 Jun 2022 13:00:44 +0200 It seems that i was a bit too much optimistic in c98b0f0. With got freshly compiled from ports i sometimes get a 'bad offset in pack file' failure. This happened in 'got status', 'got diff', ... and even in tog, in got.git and src.git. This happens very frequently thought, but not always. Curiously, this didn't happened in my local builds. Diff below fixes the issue for me. It moves the sanity check in only in the case where the object was effectively packed. This is just fixing the behaviour thought, i don't know why/how pack_offset was negative. i tried with if (obj->pack_offset < 0) abort(); in got_privsep_send_obj but couldn't get it to segfault. diff b4998ee22e6c4f0556359a5177852e33f021184d /home/op/w/got blob - 9f5f6eca6eee4371542d386c8da0e763f8bcc98a file + lib/privsep.c --- lib/privsep.c +++ lib/privsep.c @@ -1138,9 +1138,6 @@ got_privsep_get_imsg_obj(struct got_object **obj, stru return got_error(GOT_ERR_PRIVSEP_LEN); iobj = imsg->data; - if (iobj->pack_offset < 0) - return got_error(GOT_ERR_PACK_OFFSET); - *obj = calloc(1, sizeof(**obj)); if (*obj == NULL) return got_error_from_errno("calloc"); @@ -1152,6 +1149,9 @@ got_privsep_get_imsg_obj(struct got_object **obj, stru (*obj)->size = iobj->size; /* path_packfile is handled by caller */ if (iobj->flags & GOT_OBJ_FLAG_PACKED) { + if (iobj->pack_offset < 0) + return got_error(GOT_ERR_PACK_OFFSET); + (*obj)->pack_offset = iobj->pack_offset; (*obj)->pack_idx = iobj->pack_idx; }