<?xml version="1.0" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.jacorb.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://www.jacorb.org/bugzilla/"
          
          maintainer="jacorb@goots.org"
>

    <bug>
          <bug_id>996</bug_id>
          
          <creation_ts>2014-11-06 12:09:15 +0000</creation_ts>
          <short_desc>read_fixed() fails with 0</short_desc>
          <delta_ts>2014-11-19 06:33:10 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>JacORB</product>
          <component>ORB</component>
          <version>3.5</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Juergen Weber">juergen</reporter>
          <assigned_to name="Mailinglist to track bugs">jacorb-bugs</assigned_to>
          <cc>jacorb</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3212</commentid>
    <comment_count>0</comment_count>
    <who name="Juergen Weber">juergen</who>
    <bug_when>2014-11-06 12:09:15 +0000</bug_when>
    <thetext>If you send BigDecimal(new BigInteger(&quot;0&quot;)) over the wire, the receiving JacORB fails with Zero length BigInteger.

Problem is at CDRInputStream.java:897 read_fixed_internal()

For 0 the CDR representation is 0C

so (outBuffer.length() &gt; 0 || c != 0) is false || false and the 0 gets ignored.


47 49 4F 50  01 02 00 01  00 00 00 0D  00 00 00 04  GIOP .... .... .... 
00 00 00 00  00 00 00 00  0C                        .... .... .
FINE read GIOP message of size 25 from ClientGIOPConnection to 172.20.6.163:61759 (1010058)
java.lang.NumberFormatException: Zero length BigInteger
	at java.math.BigInteger.&lt;init&gt;(BigInteger.java:276)
	at java.math.BigInteger.&lt;init&gt;(BigInteger.java:451)
	at org.jacorb.orb.CDRInputStream.read_fixed(CDRInputStream.java:838)
	at demo.hello.FixedStructHelper.read(FixedStructHelper.java:41)
	at demo.hello._GoodDayStub.testFixed(_GoodDayStub.java:102)
	at demo.hello.Client.main(Client.java:65)

To reproduce:

struct FixedStruct
	{
		fixed&lt;1,0&gt; fnull; 
	};	 

        interface GoodDay {
...            
            FixedStruct testFixed(in FixedStruct fs);         
        };

return with new BigDecimal(new BigInteger(&quot;0&quot;))</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3217</commentid>
    <comment_count>1</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2014-11-07 10:34:20 +0000</bug_when>
    <thetext>Fixed with SHA de510ce7b913a3b681a194c4b1c4cbeae0497289</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3241</commentid>
    <comment_count>2</comment_count>
    <who name="Juergen Weber">juergen</who>
    <bug_when>2014-11-18 09:00:30 +0000</bug_when>
    <thetext>The code still fails if called from the deprecated read_fixed() 

(which is called from stubs generated with -generate_helper deprecated)

If called from read_fixed()  digits is -1 and the condition of the new code is false.

I think the core problem is in 

          if (outBuffer.length() &gt; 0 || c != 0)
            {
                outBuffer.append(c);
            }

which is equivalent to

if (c == 0)
    if (outBuffer.length() == 0)
       skip the character;


I do not understand why this code is there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3242</commentid>
    <comment_count>3</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2014-11-18 09:10:49 +0000</bug_when>
    <thetext>I think it relates to some changes from PrismTech - there are existing tests e.g. test/regression/src/org/jacorb/test/orb/dynany/DynAnyFixedTest.java

Can you provide a patch that fixes your scenario and doesn&apos;t break and preexisting tests?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3243</commentid>
    <comment_count>4</comment_count>
    <who name="Juergen Weber">juergen</who>
    <bug_when>2014-11-18 10:57:29 +0000</bug_when>
    <thetext>It seems to work if you change your fix to

if ((digits == 1 || digits == -1) &amp;&amp; outBuffer.length() == 0)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3244</commentid>
    <comment_count>5</comment_count>
    <who name="Juergen Weber">juergen</who>
    <bug_when>2014-11-19 05:15:01 +0000</bug_when>
    <thetext>I propose to add the digits == -1 condition and close the bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3245</commentid>
    <comment_count>6</comment_count>
    <who name="Nick Cross">jacorb</who>
    <bug_when>2014-11-19 06:33:10 +0000</bug_when>
    <thetext>Done : SHA 163ee981f523a858e6ea1d0efed586c8d52faec4</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>