Solved

InputBaseN() returns different value in ColdFusion 10 and CF2016

Posted on 2016-07-26
5
135 Views
Last Modified: 2016-08-10
We recently upgraded from CF10 to CF2016 and are now getting a 'Cannot convert the value 4.023233417E9 to an integer because it cannot fit inside an integer'. I was able to narrow it down to the initialization of the MD5 buffer. This is the code in question:
<CFSET h = ArrayNew(1)>
<CFSET h[1] = InputBaseN("0x67452301",16)>
<CFSET h[2] = InputBaseN("0xefcdab89",16)>
<CFSET h[3] = InputBaseN("0x98badcfe",16)>
<CFSET h[4] = InputBaseN("0x10325476",16)>

<cfdump var="#h#">

Open in new window


The problem is in the value being returned by the InputbaseN(). On the CF10 server the result looks like this:
1      1732584193
2      -271733879
3      -1732584194
4      271733878

However, on the server running CF2016, it looks like this:
1      1732584193
2      4023233417
3      2562383102
4      271733878

Why would the values for 2&3 change based on the CF version? And is there a way to fix this?
0
Comment
Question by:NEXT IT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 41729822
Sounds like a bug.  For whatever reason CF2016 is returning the value as a Long (bigger capacity) instead of the expected Integer.  A quick look didn't turn up any settings that might allow you to control that behavior.  I'd file a bug report.  In the mean time, you'll need a workaround. Try using Long.intValue() to get back the original integer:

<CFSET h = ArrayNew(1)>
<CFSET h[1] = InputBaseN("0x67452301",16)>
<CFSET h[2] = InputBaseN("0xefcdab89",16)>
<CFSET h[3] = InputBaseN("0x98badcfe",16)>
<CFSET h[4] = InputBaseN("0x10325476",16)>

<cfoutput>
<cfloop array="#h#" index="longValue">
	<br> Long = #longValue# / Integer = #javacast("long", longValue).intValue()#
</cfloop>
</cfoutput>

Open in new window


Result:
Long = 1732584193 / Integer = 1732584193
Long = 4023233417 / Integer = -271733879
Long = 2562383102 / Integer = -1732584194
Long = 271733878 / Integer = 271733878
0
 

Author Closing Comment

by:NEXT IT
ID: 41729980
Thanks for the help - worked like a charm. Gonna add this to their bug tracker and hope this isn't another one of Adobe's "undocumented features"
0
 
LVL 52

Expert Comment

by:_agx_
ID: 41730044
Yeah, hope not but ... it's kind of a weird change. CF has always had a 32 bit int limit for most functions. To suddenly start returning an unsigned long value without warning ... smacks of something "undocumented" ;-)
0
 

Author Comment

by:NEXT IT
ID: 41733239
Just to circle back on  this... we filed bug https://bugbase.adobe.com/index.cfm?event=bug&id=4175842 with Adobe.

Adobe then came back and said the behavior in CF10 and CF11 was actually wrong they "fixed" it in CF2016 Update 2.  They referenced CF10 bug:

https://bugbase.adobe.com/index.cfm?event=bug&id=3712098

I'm pretty sure our code had worked on CF versions prior to CF10 without issue as well so I'm not sure this explains that, but I can't remember that far back to say for certain.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 41733468
Interesting. Though I am not sure I agree with how they handled it.  CF's long been known to have a 32bit int limit for most functions and operators. So of course some numbers may be too large, and could obviously be truncated when converted to an INT. However, the documentation says:

Description:  Converts string, using the base specified by radix, to an integer.

To me that says the expected result should be an integer. To suddenly decide it will now be a Long, or some other type, breaks backward compatibility.  Why not throw an error, or add a new parameter/setting that defaults to the old behavior, but allows developers to chose which behavior they want on a per app basis?  BTW, if the function is no longer returning a 32 bit integer - do you know what is it returning? I didn't see that mentioned in either bug report.  I'm guessing:

http://docs.oracle.com/javase/7/docs/api/java/lang/Long.html#MIN_VALUE
http://docs.oracle.com/javase/7/docs/api/java/lang/Long.html#MAX_VALUE

?

I'm pretty sure our code had worked on CF versions prior to CF10 without issue

Well I suppose if it's something simply dependent on matching output like hashing, or the other system uses ints too, in theory it might work either way.
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
One of Google's most recent algorithm changes affecting local searches is entitled "The Pigeon Update." This update has dramatically enhanced search inquires for the keyword "Yelp." Google searches with the word "Yelp" included will now yield Yelp a…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question