public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum
@ 2021-12-02 13:38 Oguz Bektas
  2021-12-03  8:03 ` Fabian Ebner
  0 siblings, 1 reply; 4+ messages in thread
From: Oguz Bektas @ 2021-12-02 13:38 UTC (permalink / raw)
  To: pve-devel

so that we don't get checksum mismatch in case the user accidentally
copies whitespace in the checksum field.

Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
 src/PVE/Tools.pm | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
index 787942a..fa14f2f 100644
--- a/src/PVE/Tools.pm
+++ b/src/PVE/Tools.pm
@@ -1921,6 +1921,7 @@ sub download_file_from_url {
 	if (defined($opts->{"${_}sum"})) {
 	    $checksum_algorithm = $_;
 	    $checksum_expected = $opts->{"${_}sum"};
+	    $checksum_expected =~ s/^\s+|\s+$//g;
 	    last;
 	}
     }
-- 
2.30.2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum
  2021-12-02 13:38 [pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum Oguz Bektas
@ 2021-12-03  8:03 ` Fabian Ebner
  2021-12-03  9:20   ` Fabian Grünbichler
  2021-12-03 10:11   ` Thomas Lamprecht
  0 siblings, 2 replies; 4+ messages in thread
From: Fabian Ebner @ 2021-12-03  8:03 UTC (permalink / raw)
  To: pve-devel, Oguz Bektas

Am 02.12.21 um 14:38 schrieb Oguz Bektas:
> so that we don't get checksum mismatch in case the user accidentally
> copies whitespace in the checksum field.
> 

Isn't this better done in the UI? Or at least upon parameter validation 
(but we don't do this for any other parameter, or)?.

> Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
> ---
>   src/PVE/Tools.pm | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> index 787942a..fa14f2f 100644
> --- a/src/PVE/Tools.pm
> +++ b/src/PVE/Tools.pm
> @@ -1921,6 +1921,7 @@ sub download_file_from_url {
>   	if (defined($opts->{"${_}sum"})) {
>   	    $checksum_algorithm = $_;
>   	    $checksum_expected = $opts->{"${_}sum"};
> +	    $checksum_expected =~ s/^\s+|\s+$//g;
>   	    last;
>   	}
>       }
> 




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum
  2021-12-03  8:03 ` Fabian Ebner
@ 2021-12-03  9:20   ` Fabian Grünbichler
  2021-12-03 10:11   ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Fabian Grünbichler @ 2021-12-03  9:20 UTC (permalink / raw)
  To: Oguz Bektas, Proxmox VE development discussion

On December 3, 2021 9:03 am, Fabian Ebner wrote:
> Am 02.12.21 um 14:38 schrieb Oguz Bektas:
>> so that we don't get checksum mismatch in case the user accidentally
>> copies whitespace in the checksum field.
>> 
> 
> Isn't this better done in the UI? Or at least upon parameter validation 
> (but we don't do this for any other parameter, or)?.
> 
>> Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
>> ---
>>   src/PVE/Tools.pm | 1 +
>>   1 file changed, 1 insertion(+)
>> 
>> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
>> index 787942a..fa14f2f 100644
>> --- a/src/PVE/Tools.pm
>> +++ b/src/PVE/Tools.pm
>> @@ -1921,6 +1921,7 @@ sub download_file_from_url {
>>   	if (defined($opts->{"${_}sum"})) {
>>   	    $checksum_algorithm = $_;
>>   	    $checksum_expected = $opts->{"${_}sum"};
>> +	    $checksum_expected =~ s/^\s+|\s+$//g;

PVE::Tools::trim ?

>>   	    last;
>>   	}
>>       }
>> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum
  2021-12-03  8:03 ` Fabian Ebner
  2021-12-03  9:20   ` Fabian Grünbichler
@ 2021-12-03 10:11   ` Thomas Lamprecht
  1 sibling, 0 replies; 4+ messages in thread
From: Thomas Lamprecht @ 2021-12-03 10:11 UTC (permalink / raw)
  To: Proxmox VE development discussion, Fabian Ebner, Oguz Bektas

On 03.12.21 09:03, Fabian Ebner wrote:
> Am 02.12.21 um 14:38 schrieb Oguz Bektas:
>> so that we don't get checksum mismatch in case the user accidentally
>> copies whitespace in the checksum field.
>>
> 
> Isn't this better done in the UI? Or at least upon parameter validation (but we don't do this for any other parameter, or)?.
> 

Yeah, I do not like messing with the checksum in the backend to much,
maybe we can enforce the format such that it doesn't allow any whitespace
and explicitly errors out for api users that send some.

I trimmed for now in the frontend:

https://git.proxmox.com/?p=pve-manager.git;a=commitdiff;h=9e9a3abd0a5eedc76a41f6ebcd719dca72d536b8




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-03 10:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 13:38 [pve-devel] [PATCH common] fix #3747: download_file_from_url: trim whitespace before comparing checksum Oguz Bektas
2021-12-03  8:03 ` Fabian Ebner
2021-12-03  9:20   ` Fabian Grünbichler
2021-12-03 10:11   ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal