Re: [Plugins-writers] Converting a string to an int that's greater than 2^31-1

From: Jon Passki (cykyc@private)
Date: Sat Oct 08 2005 - 06:49:11 PDT


--- "George A. Theall" <theall@private> wrote:

> On Thu, Oct 06, 2005 at 09:32:06AM -0700, Jon Passki wrote:
> 
> > I'm tweaking my first plugin that I'm about ready to spam the
> list
> > with, but I'm having a situation where I'm given a string that
> > represents a long int.  I.e., the decimal value is greater than
> > 2147483647.  How can I convert that string into an int without
> > losing any information?
> 
> I don't think you can - NASL doesn't support long ints. Can you
> write
> your code so it looks at the value as composed of multiple parts?

  # Hack to convert a string that represents a value greater than
2^31 -1
  # Look away!
  if (strlen(pieces[1]) > 9) {
  	bottom = int( substr(pieces[1],5) );
	top = int( substr(pieces[1],0,4) );
	pieces[1] = top * 10**5 + bottom; 
  }


That's my hack for now.  So, any number > 999999999 will be
converted.  This unnecessarily converts strings representing
numbers < 2^31 - 1, but whatever :)  It's straight-forward and
seems to work in my testing :D

Jon



		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs
_______________________________________________
Plugins-writers mailing list
Plugins-writers@private
http://mail.nessus.org/mailman/listinfo/plugins-writers



This archive was generated by hypermail 2.1.3 : Sat Oct 08 2005 - 06:49:37 PDT