<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>16153</bug_id>
          
          <creation_ts>2026-01-27 20:13:16 +0000</creation_ts>
          <short_desc>wget fetcher garble file if upstream is corrupted and mirror has a bigger file</short_desc>
          <delta_ts>2026-10-06 22:53:04 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>6.1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yoann Congal">yoann.congal</reporter>
          <assigned_to name="Unassigned">unassigned</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>tgamblin</cc>
    
    <cc>tim.orling</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>104082</commentid>
    <comment_count>0</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2026-01-27 20:13:16 +0000</bug_when>
    <thetext>When:
* SRC_URI = &quot;http://...&quot; (the wget fetcher is used), 
* SRC_URI[sha256sum] does not match what is downloaded and
* the yp.org MIRRORS has a matching file that is bigger than the downloaded file
Then, the fetcher fail to correctly download the file.

What happen is:
* The fetcher downloads the corrupted file
* The file does not match the hash so this is considered a failure to download
* The mirror is tried *with the wget --continue* option[0].
* The mirrored file being bigger, the download is &quot;continued&quot; by wget: the end of the mirrored file is appended to the corrupted file.
* The resulting file does not match the recipe hash as well so the fetch task fails.

I guess we could:
* remove the .tmp file between upstream/mirror tries
* remove the --continue argument of wget: (see wget manpage[1]):
&gt; However, if the file is bigger on the server because it’s been changed, as
&gt; opposed to just appended to, *you’ll end up with a garbled file*. Wget has no
&gt; way of verifying that the local file is really a valid prefix of the remote
&gt; file. You need to be especially careful of this when using ‘-c’ in
&gt; conjunction with ‘-r’, since every file will be considered as an &quot;incomplete
&gt; download&quot; candidate.

I would remove --continue but I&apos;ve yet to track down why it was added in the first place (it was before the fetch -&gt; fetch2 migration, 14 years ago)

See: the meta-oe issue that triggered this bug: https://github.com/openembedded/meta-openembedded/issues/1023 (patch for it was sent https://lists.openembedded.org/g/openembedded-devel/message/123959)

[0]: https://github.com/openembedded/bitbake/blob/cdd79c1768ac396a9c6577e38098da4331507f24/lib/bb/fetch2/wget.py#L125
[1]: https://www.gnu.org/software/wget/manual/wget.html#index-continue-retrieval</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>104099</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-01-29 15:47:24 +0000</bug_when>
    <thetext>This can still be useful for large downloads that get interrupted
but there may be too many cases where --continue is wrong.

Maybe we should change the point where the renaming happens.

It would be nice to add a test case as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>105617</commentid>
    <comment_count>2</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-05-28 13:16:30 +0000</bug_when>
    <thetext>Bulk move of 6.0 Medium bugs to 6.1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107024</commentid>
    <comment_count>3</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2026-10-06 22:53:04 +0000</bug_when>
    <thetext>This merged patch sounds related:
fetch/wget: rename the partial download on checksum mismatch
https://git.openembedded.org/bitbake/commit/?id=37b9c56ae3b2294ad170859a638c879910c82c59

and its follow-up:
[PATCH] fetch/wget: rename the partial download on checksum mismatch
https://lore.kernel.org/bitbake-devel/20261006213334.3360919-1-ricardo.salveti@oss.qualcomm.com/T/#u</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>