patch 命令出错(fuzz)

本文探讨了使用patch工具给kernel打补丁时遇到的模糊匹配问题,解释了默认fuzz factor的影响,并提供了解决方案,建议关闭默认fuzz并使用dry-run测试。

最近使用patch给kernel打补丁的时候,遇到一个诡异的问题。发现patch会把没匹配上的代码也打上去。这会导致失败。
经过对比,发现patch还有个模糊匹配打patch.
patch -f
而且还有个默认的factor为2.
在这里插入图片描述
所以说为了安全起见,还是关闭默认的fuzz

-F 0

再结合dry-run去探测是否能打成功。

patch -p1 < /home/lhl/ga-sig/sig/device/soc/spreadtrum/patches/third_party/wpa_supplicant/0001_wpa_supplicant_add-sae-support.patch patching file wpa_supplicant-2.9_standard/src/ap/ap_config.h Hunk #1 succeeded at 252 (offset 6 lines). patching file wpa_supplicant-2.9_standard/src/ap/beacon.c Hunk #1 succeeded at 2661 with fuzz 2 (offset 808 lines). patching file wpa_supplicant-2.9_standard/src/ap/drv_callbacks.c Hunk #1 succeeded at 60 with fuzz 1 (offset 5 lines). Hunk #2 succeeded at 558 (offset 181 lines). Hunk #3 succeeded at 899 (offset 198 lines). Hunk #4 succeeded at 962 (offset 203 lines). patching file wpa_supplicant-2.9_standard/src/ap/ieee802_11.c Hunk #2 succeeded at 542 (offset 60 lines). patching file wpa_supplicant-2.9_standard/src/ap/ieee802_11.h Hunk #1 succeeded at 155 (offset 30 lines). patching file wpa_supplicant-2.9_standard/src/common/ieee802_11_defs.h Hunk #1 succeeded at 1434 (offset 61 lines). patching file wpa_supplicant-2.9_standard/src/common/sae.h patching file wpa_supplicant-2.9_standard/src/common/wpa_common.c Hunk #1 succeeded at 1738 (offset 245 lines). patching file wpa_supplicant-2.9_standard/src/common/wpa_common.h Hunk #1 succeeded at 487 with fuzz 2 (offset 27 lines). patching file wpa_supplicant-2.9_standard/src/crypto/tls_openssl.c Hunk #1 succeeded at 2724 (offset 131 lines). patching file wpa_supplicant-2.9_standard/src/drivers/driver.h Hunk #1 succeeded at 4388 (offset 441 lines). Hunk #2 succeeded at 4399 (offset 441 lines). Hunk #3 succeeded at 4712 (offset 453 lines). patching file wpa_supplicant-2.9_standard/src/drivers/driver_nl80211.c Hunk #1 succeeded at 12134 (offset 1170 lines). Hunk #2 succeeded at 14326 (offset 1484 lines). Hunk #3 succeeded at 14368 with fuzz 2 (offset 1489 lines). patching file wpa_supplicant-2.9_standard/src/drivers/driver_nl80211.h Hunk #1 succeeded at 374 with fuzz 2 (offset 41 lines). patching file wpa_supplicant-2.9_standard/src/drivers/driver_nl80211_capa.c Hunk #1 succeeded at 260 (offset -1 lines). Hunk #2 succeeded at 275 (offset -1 lines). Hunk #3 succeeded at 284 (offset -1 lines). patching file wpa_supplicant-2.9_standard/wpa_supplicant/driver_i.h Hunk #1 succeeded at 787 (offset -14 lines). patching file wpa_supplicant-2.9_standard/wpa_supplicant/events.c patch: **** malformed patch at line 603: diff --git a/wpa_supplicant-2.9_standard/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant-2.9_standard/wpa_supplicant/p2p_supplicant.c
07-13
install -d -m0755 /ge550v1/qca_95xx_12_2/bin/targets/ipq95xx/generic/packages /ge550v1/qca_95xx_12_2/scripts/ipkg-build -c -o 0 -g 0 /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/linux-ipq95xx_generic/base-files/ipkg-aarch64_cortex-a73_neon-vfpv4/base-files /ge550v1/qca_95xx_12_2/bin/targets/ipq95xx/generic/packages /ge550v1/qca_95xx_12_2/staging_dir/host/bin/find: '/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/linux-ipq95xx_generic/base-files/ipkg-aarch64_cortex-a73_neon-vfpv4/base-files/etc/config/network': No such file or directory /ge550v1/qca_95xx_12_2/staging_dir/host/bin/find: '/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/linux-ipq95xx_generic/base-files/ipkg-aarch64_cortex-a73_neon-vfpv4/base-files/etc/config/system': No such file or directory /ge550v1/qca_95xx_12_2/staging_dir/host/bin/find: '/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/linux-ipq95xx_generic/base-files/ipkg-aarch64_cortex-a73_neon-vfpv4/base-files/etc/dropbear/': No such file or directory /ge550v1/qca_95xx_12_2/staging_dir/host/bin/find: '/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/linux-ipq95xx_generic/base-files/ipkg-aarch64_cortex-a73_neon-vfpv4/base-files/etc/profile.d': No such file or directory Packaged contents of /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/linux-ipq95xx_generic/base-files/ipkg-aarch64_cortex-a73_neon-vfpv4/base-files into /ge550v1/qca_95xx_12_2/bin/targets/ipq95xx/generic/packages/base-files_204.4-12.02.2392_aarch64_cortex-a73_neon-vfpv4.ipk echo "base-files" >> /ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/pkginfo/base-files.default.install make[4]: Leaving directory `/ge550v1/qca_95xx_12_2/package/base-files' time: package/base-files/compile#0.45#0.08#0.55 make[4]: Entering directory `/ge550v1/qca_95xx_12_2/package/boot/uboot-envtools' mkdir -p /ge550v1/qca_95xx_12_2/dl SHELL= flock /ge550v1/qca_95xx_12_2/tmp/.u-boot-2022.01.tar.bz2.flock -c ' /ge550v1/qca_95xx_12_2/scripts/download.pl "/ge550v1/qca_95xx_12_2/dl" "u-boot-2022.01.tar.bz2" "81b4543227db228c03f8a1bf5ddbc813b0bb8f6555ce46064ef721a6fc680413" "" "https://ftp.denx.de/pub/u-boot" ' touch /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.prepared_37da1ec8733136d808e634953c70acb0_6664517399ebbbc92a37c5bb081b5c53_check . /ge550v1/qca_95xx_12_2/include/shell.sh; bzcat /ge550v1/qca_95xx_12_2/dl/u-boot-2022.01.tar.bz2 | tar -C /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.. -xf - [ ! -d ./src/ ] || cp -fpR ./src/. /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01 Applying ./patches/001-compile.patch using plaintext: patching file tools/env/Makefile Hunk #1 succeeded at 8 with fuzz 2. Applying ./patches/303-fix-bad-block-present-calculation.patch using plaintext: patching file tools/env/fw_env.c Hunk #1 succeeded at 885 (offset 2 lines). Hunk #2 succeeded at 910 with fuzz 2 (offset 2 lines). Hunk #3 succeeded at 930 with fuzz 2 (offset 2 lines). Hunk #4 succeeded at 951 with fuzz 2 (offset 2 lines). Hunk #5 succeeded at 1022 (offset -27 lines). Hunk #6 succeeded at 1042 (offset -27 lines). Hunk #7 succeeded at 1123 (offset -27 lines). Applying ./patches/304-fix_default_bootcmd.patch using plaintext: patching file tools/env/fw_env_private.h Hunk #1 succeeded at 41 (offset -1 lines). Hunk #2 succeeded at 53 (offset -1 lines). touch /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.prepared_37da1ec8733136d808e634953c70acb0_6664517399ebbbc92a37c5bb081b5c53 if [[ "" == *'s'* ]]; then [[ -f "/ge550v1/qca_95xx_12_2/scripts/fossid.sh" ]] && /ge550v1/qca_95xx_12_2/scripts/fossid.sh --build_scan "ipq95xx" "generic" "/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01" "/ge550v1/qca_95xx_12_2/build_dir/target-aarch64" "" || echo "/ge550v1/qca_95xx_12_2/scripts/fossid.sh is missing"; fi rm -f /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.configured_* rm -f /ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/stamp/.uboot-envtools_installed touch /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/include/config.h mkdir -p /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/include/config touch /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/include/config/auto.conf mkdir -p /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/include/generated touch /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/include/generated/autoconf.h touch /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.configured_68b329da9893e34099c7d8ad5cb9c940 rm -f /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.built touch /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.built_check CFLAGS="-Os -pipe -march=armv8-a -mcpu=cortex-a73+crypto -fno-caller-saves -fno-plt -Wa,--noexecstack -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01:u-boot-2022.01 -Wformat -Werror=format-security -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -I/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/usr/include -I/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/include -I/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/usr/include -I/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/include/fortify -I/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/include " CXXFLAGS="-Os -pipe -march=armv8-a -mcpu=cortex-a73+crypto -fno-caller-saves -fno-plt -Wa,--noexecstack -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01:u-boot-2022.01 -Wformat -Werror=format-security -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -I/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/usr/include -I/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/include -I/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/usr/include -I/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/include/fortify -I/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/include " LDFLAGS="-L/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/usr/lib -L/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/lib -L/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/usr/lib -L/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/lib -fPIC -specs=/ge550v1/qca_95xx_12_2/include/hardened-ld-pie.specs -znow -zrelro " make -C /ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/. AR="aarch64-openwrt-linux-musl-gcc-ar" AS="aarch64-openwrt-linux-musl-gcc -c -Os -pipe -march=armv8-a -mcpu=cortex-a73+crypto -fno-caller-saves -fno-plt -Wa,--noexecstack -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01:u-boot-2022.01 -Wformat -Werror=format-security -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro" LD=aarch64-openwrt-linux-musl-ld NM="aarch64-openwrt-linux-musl-gcc-nm" CC="aarch64-openwrt-linux-musl-gcc" GCC="aarch64-openwrt-linux-musl-gcc" CXX="aarch64-openwrt-linux-musl-g++" RANLIB="aarch64-openwrt-linux-musl-gcc-ranlib" STRIP=aarch64-openwrt-linux-musl-strip OBJCOPY=aarch64-openwrt-linux-musl-objcopy OBJDUMP=aarch64-openwrt-linux-musl-objdump SIZE=aarch64-openwrt-linux-musl-size CROSS="aarch64-openwrt-linux-musl-" ARCH="aarch64" TARGET_CFLAGS="-Os -pipe -march=armv8-a -mcpu=cortex-a73+crypto -fno-caller-saves -fno-plt -Wa,--noexecstack -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01:u-boot-2022.01 -Wformat -Werror=format-security -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro" TARGET_LDFLAGS="-L/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/usr/lib -L/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/lib -L/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/usr/lib -L/ge550v1/qca_95xx_12_2/staging_dir/toolchain-aarch64/lib -fPIC -specs=/ge550v1/qca_95xx_12_2/include/hardened-ld-pie.specs -znow -zrelro" no-dot-config-targets=envtools envtools ; make[5]: Entering directory `/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01' Makefile:40: *** missing separator. Stop. make[5]: Leaving directory `/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01' make[4]: *** [/ge550v1/qca_95xx_12_2/build_dir/target-aarch64/u-boot-2022.01/.built] Error 2 make[4]: Leaving directory `/ge550v1/qca_95xx_12_2/package/boot/uboot-envtools' time: package/boot/uboot-envtools/compile#2.08#0.43#2.31 make[3]: *** [package/boot/uboot-envtools/compile] Error 2 make[3]: Leaving directory `/ge550v1/qca_95xx_12_2' make[2]: *** [/ge550v1/qca_95xx_12_2/staging_dir/target-aarch64/stamp/.package_compile] Error 2 make[2]: Leaving directory `/ge550v1/qca_95xx_12_2' make[1]: *** [world] Error 2 make[1]: Leaving directory `/ge550v1/qca_95xx_12_2' make: *** [sdk] Error 2 huaxi@fd4bb9d5f3ca:/ge550v1/Iplatform/build$ cat ./patches/304-fix_default_bootcmd.patch | grep "Makefile" cat: ./patches/304-fix_default_bootcmd.patch: No such file or directory huaxi@fd4bb9d5f3ca:/ge550v1/Iplatform/build$
最新发布
09-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值