Solved

InputBaseN() returns different value in ColdFusion 10 and CF2016

Posted on 2016-07-26
5
64 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
  • 3
  • 2
5 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
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_
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now