Skip to contentSkip to conversation

support/download/file: fix file:// protocol handling

PATCH New Angelo Compagnucci 4 participants 4 messages May 8, 2018 – May 13, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 support/download/file: fix file:// protocol handling

When a file is used a source for download using the file:// protocol, a malformed url is passed to the file download script which then crashes. Following an example of a wrong path passed to the script:

eval cp -v ''\''file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2'\''' ''\''/home/angelo/DEV/BUILDROOT/br_qemu_arm/build/.armv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2.f403PT/output'\'''.

Path passed to cp lacks of a / between dir and file part of the url, moreover it presents a wrong file:// prefix.

Fixes:

cp: cannot stat 'file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2':
No such file or directory

---
 support/download/file | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
support/download/file +1 -1
index fefd6d2..6dd37b0 100755
@@ -40,4 +40,4 @@ _localfiles() {
     eval ${LOCALFILES} "${@}"
 }
 
-_localfiles ${verbose} "'${dir}${file}'" "'${output}'"
+_localfiles ${verbose} "'${dir##file://}/${file}'" "'${output}'"
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/1 support/download/file: fix file:// protocol handling

Angelo, All,

Thanks for the respin.

On 2018-05-08 15:28 +0200, Angelo Compagnucci spake thusly:

Quoted 8 lines

When a file is used a source for download using the file:// protocol, a malformed url is passed to the file download script which then crashes. Following an example of a wrong path passed to the script:

eval cp -v ''\''file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2'\''' ''\''/home/angelo/DEV/BUILDROOT/br_qemu_arm/build/.armv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2.f403PT/output'\'''.

Path passed to cp lacks of a / between dir and file part of the url, moreover it presents a wrong file:// prefix.

Well, the misisng / is indeed incorrect.

However, the leading protocol is expected: the dl-wrapper calls all backend scripts with the exact same set of options and semantics. It's is then up to the backend scripts to interpret that as they see fit.

So, it is not "semantically wrong"; it *is* correct.

The bug lies in the fact that the 'file' backend did not strip out the protocol part when calling the actual tool; we missed that during the download overhaul.

Regards,
Yann E. MORIN.

Quoted 24 lines

Fixes:

cp: cannot stat 'file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2':
No such file or directory

---
 support/download/file | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
support/download/file +1 -1
index fefd6d2..6dd37b0 100755
@@ -40,4 +40,4 @@ _localfiles() {
     eval ${LOCALFILES} "${@}"
 }
 
-_localfiles ${verbose} "'${dir}${file}'" "'${output}'"
+_localfiles ${verbose} "'${dir##file://}/${file}'" "'${output}'"
Signature · 1 line
2.7.4
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#2 lore raw

PATCH v2 1/1 support/download/file: fix file:// protocol handling

Dear Yann,

2018-05-08 15:34 GMT+02:00 Yann E. MORIN <[email protected]>:

Quoted 20 lines

Angelo, All,

Thanks for the respin.

On 2018-05-08 15:28 +0200, Angelo Compagnucci spake thusly:

Quoted 8 lines

When a file is used a source for download using the file:// protocol, a malformed url is passed to the file download script which then crashes. Following an example of a wrong path passed to the script:

eval cp -v ''\''file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2'\''' ''\''/home/angelo/DEV/BUILDROOT/br_qemu_arm/build/.armv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2.f403PT/output'\'''.

Path passed to cp lacks of a / between dir and file part of the url, moreover it presents a wrong file:// prefix.

Well, the misisng / is indeed incorrect.

However, the leading protocol is expected: the dl-wrapper calls all backend scripts with the exact same set of options and semantics. It's is then up to the backend scripts to interpret that as they see fit.

Quoted 5 lines

So, it is not "semantically wrong"; it *is* correct.

The bug lies in the fact that the 'file' backend did not strip out the protocol part when calling the actual tool; we missed that during the download overhaul.

Indeed I said "path passed to cp" not to the file backend. That is incorrect.

Should I rework my commit message?

Quoted 42 lines

Regards,
Yann E. MORIN.

Quoted 22 lines

Fixes:

cp: cannot stat 'file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2':
No such file or directory

---
 support/download/file | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
support/download/file +1 -2
index fefd6d2..6dd37b0 100755
@@ -40,4 +40,4 @@ _localfiles() {
     eval ${LOCALFILES} "${@}"
 }
 
-_localfiles ${verbose} "'${dir}${file}'" "'${output}'"
+_localfiles ${verbose} "'${dir##file://}/${file}'" "'${output}'"
--
Quoted 2 lines

2.7.4

--
.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |

'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot

Signature · 1 line
Profile: http://it.linkedin.com/in/compagnucciangelo
#3 lore raw

PATCH v2 1/1 support/download/file: fix file:// protocol handling

In reply to Angelo Compagnucci

Hello,

Quoted 11 lines · Angelo Compagnucci

When a file is used a source for download using the file:// protocol, a malformed url is passed to the file download script which then crashes. Following an example of a wrong path passed to the script:

eval cp -v ''\''file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2'\''' ''\''/home/angelo/DEV/BUILDROOT/br_qemu_arm/build/.armv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2.f403PT/output'\'''.

Path passed to cp lacks of a / between dir and file part of the url, moreover it presents a wrong file:// prefix.

Fixes:

Quoted 8 lines

cp: cannot stat 'file:///home/angelo/DEV/TOOLCHAINSarmv7-eabihf--glibc--bleeding-edge-2017.11-1.tar.bz2':
No such file or directory

---
 support/download/file | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to master after reworking the commit log. Thanks Angelo!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com