tool_getparam: Support size modifiers for --max-filesize #2179

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Owner

jay commented Dec 17, 2017

  • Move the size modifier detection code from limit-rate to its own
    function so that it can also be used with max-filesize.

Size modifiers are the suffixes such as G (gigabyte), M (megabyte) etc.

For example --max-filesize 1G

Ref: https://curl.haxx.se/mail/archive-2017-12/0000.html

Closes #xxxx


As proposed by @gvanem on the curl tool mailing list. I modified it slightly for error, doc and checksrc compliance.

tool_getparam: Support size modifiers for --max-filesize
- Move the size modifier detection code from limit-rate to its own
  function so that it can also be used with max-filesize.

Size modifiers are the suffixes such as G (gigabyte), M (megabyte) etc.

For example --max-filesize 1G

Ref: https://curl.haxx.se/mail/archive-2017-12/0000.html

Closes #xxxx

@jay jay added the cmdline tool label Dec 17, 2017

+ switch(*unit) {
+ case 'G':
+ case 'g':
+ value *= 1024*1024*1024;
@bagder

bagder Dec 21, 2017

Owner

while fixing this, we should probably also fix the code to avoid the risk for integer overflows in these multiplications and instead return an error if that large values are used!

@jay jay closed this in 859ac36 Dec 26, 2017

@jay jay deleted the jay:add_size_modifier_for_max-filesize branch Dec 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment