info-mtools
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Info-mtools] [PATCH] misc.c: Make the output reproducible


From: Chris Lamb
Subject: Re: [Info-mtools] [PATCH] misc.c: Make the output reproducible
Date: Mon, 29 Oct 2018 17:45:55 -0400

Hi Pali,

Thank you again for your comments.

> You are using strtoull() function which returns unsigned value and does
> *not* signal overflow by design. You need to use strtoll() which returns
> signed integer and then you can check underflow by above code.

Can't quite parse this; so simply strtoll → strtoull will "just work" in
that I already check errno for ERANGE?

> > > 2) Leading (whitespace) garbage.
[..]
> And this is my question. It is OK that you accept value which has
> leading whitespaces, but do not accept value which has trailing
> whitespaces?

Well, it is mostly to detect trailing garbage such as the value:

  "1this-is-not-valid-or-some-kind-of-mistake"
  
> It is pity that such common operation "convert string to number" is hard
> to write correctly in C.

Indeed. (I guess it keeps the security folks employed, mind you...)


Regards,

-- 
      ,''`.
     : :'  :     Chris Lamb
     `. `'`      address@hidden / chris-lamb.co.uk
       `-



reply via email to

[Prev in Thread] Current Thread [Next in Thread]