From nobody Thu Jan 30 20:33:30 2025 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YkW220TSWz5mdj2 for ; Thu, 30 Jan 2025 20:33:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YkW2172Tjz3GhY for ; Thu, 30 Jan 2025 20:33:29 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738269210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9epat/KcC3y9I1SAwieS/9iDf8jaH3n+Ci/Z02ANfQA=; b=tN0IWsTEJGWca2sL4gnl5CVd6agv99YaHX60m/p6gQ7ae0UBnxLf5KnsMfrGgmSiDuj9QD CbvuS8zi4OpvuGOwSxKLa41SqkCXNnNdljPnZ4v7zbTe3xjUcESNKgftv6BNPWW1ACCVjC 4rrzoom1t/Pz98mv1qA3I5qO7x9TLvYkOk8qEk0LdFNjzOEn49bj5G1ycyoqOYSbEg+hBQ /uqIJYeTKzRMdaCvC8g4EvTsKDzJ8gBxY5auIHhHGvYtUS/9fCMMlFdFWfqw/wTBWwxMIL 8KQEXg4cWmapY4eXiAaR/Lidv87/D20eIEaLP8t9DuVxKby9dac5W71bjpqJ7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738269210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9epat/KcC3y9I1SAwieS/9iDf8jaH3n+Ci/Z02ANfQA=; b=SoPsYFVy+mGfV1pQWlP0QzxTaKtjfXq5V5NJk/rl78CVArkV9xOUV2N5+/BEjLDEsm8F39 4FEdIqI5CfD/klBHPcCktlPEr+xX3vqPdob5fofbGHbzXEX0D0on3JD1u8P6rQreLbt15e PUDEyPcDxqZ9M+FLkq3TyHxHD9ExNQXdCLRy7FTqvKQf64RM5jhlq3yI90Axq/HbgUQe// xpO9/5d0yJ1FMjQ149etiummdjbwDLXRLvdWLgemQrXKPeNQtzBWT33vjgwhUYuYw7wFu1 XbLY8f0N4U4ESI/oxwXmib6VNeQI3SsYjhch12w0m5kPMHevFyjceaWjCKKGSQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738269210; a=rsa-sha256; cv=none; b=WJvYYAgEC58iZuhgjGesqqgRNzSEwtwr1SXblZVlBHz6bN72/vKRIurw3TqxQI+3Kqld3y tWvTt4GwhjNg/dO/S0uu6yG3+xKfA58S9LfK87zumfAcI4PyiPSFH//kKFl0Z6DM/0/LHD fVpa9PM5ovQJ2GltOad1sxKw/piFQwaFypUMVCDRJqPbqqQ0it0i54OZqJWDqBsXF3woiW yPR08Nc5VugVteutz1MOUdC0AI3eX4K2E+d+jLoILW9LDgUFsfZB1KvUMGFvJtjq0VQZ6Q i2xnHVqPInaYvHfkWCU9OvyouHt9ZXkCEu8Q2Bv+3E3Q5wASOqJrT4mCV2IuXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YkW216TTdz13Qr for ; Thu, 30 Jan 2025 20:33:29 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 50UKXTGU097349 for ; Thu, 30 Jan 2025 20:33:29 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 50UKXT3c097348 for bugs@FreeBSD.org; Thu, 30 Jan 2025 20:33:29 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 284472] bspatch(1): still one "attack vector" Date: Thu, 30 Jan 2025 20:33:30 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: steffen@sdaoden.eu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@FreeBSD.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D284472 Bug ID: 284472 Summary: bspatch(1): still one "attack vector" Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: steffen@sdaoden.eu i had shared the following in private already, but since the code has not b= een fixed i simply create a bug report. |The problem is that at the end of the loop there is a | | /* Adjust pointers */ | - newpos+=3Dctrl[1]; | - oldpos+=3Dctrl[2]; | + newpos =3D add_off_t(newpos, ctrl[1]); | + oldpos =3D add_off_t(oldpos, ctrl[2]); | |but before that we have | | /* Add old data to diff string */ | for (i =3D 0; i < ctrl[0]; i++) | - if ((oldpos + i >=3D 0) && (oldpos + i < oldsiz= e)) | + if (add_off_t(oldpos, i) < oldsize) | new[newpos + i] +=3D old[oldpos + i]; | |of if ctrl[2] is only "negative enough" then in the next loop tick |old will be accessed at a negative offset, i would think. (I think analysis was right.) btw i have created a "bsdipa" fork which is, i think, an iterated variant of bsdiff/bspatch: s-bsdipa (ZLIB; 0.5.3): create or apply binary difference patch s-bsdipa [!]patch after patch restored s-bsdipa [!]diff before after patch s-bsdipa [!]xdiff before after patch s-bsdipa [!]diff/VAL before after patch The first uses "patch" to create "restored" from "after". The latter create "patch" from the difference of "after" and "before"; they differ in the size of the "magic window": diff uses the built-in value, xdiff uses 16, whereas diff/VAL expects a positive integer to be used inste= ad. An existing target is overwritten if the subcommand is prefixed with "!". Some statistics are written on standard output. . Patches use ZLIB compression. Adding a zstd variant would be easy. --=20 You are receiving this mail because: You are the assignee for the bug.=