Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the default maximum length of the value set incorrectly? #49

Open
overcat opened this issue Mar 4, 2020 · 1 comment
Open

Is the default maximum length of the value set incorrectly? #49

overcat opened this issue Mar 4, 2020 · 1 comment
Labels

Comments

@overcat
Copy link
Contributor

overcat commented Mar 4, 2020

What version are you using?

the lastest code from master branch.

What did you do?

Please look at the following two lines of code, we set the maximum value to 2 ** 31 - 1
https://github.com/stellar/xdrgen/blob/master/lib/xdrgen/generators/javascript.rb#L5
https://github.com/stellar/xdrgen/blob/master/lib/xdrgen/generators/javascript.rb#L238

I just read RFC 4506 and its description is as follows in 4.10, 4.11 and 4.13, so I think we should set the maximum value to (2**32) - 1.

4.13.  Variable-Length Array

   Counted arrays provide the ability to encode variable-length arrays
   of homogeneous elements.  The array is encoded as the element count n
   (an unsigned integer) followed by the encoding of each of the array's
   elements, starting with element 0 and progressing through element
   n-1.  The declaration for variable-length arrays follows this form:

         type-name identifier<m>;
      or
         type-name identifier<>;

   The constant m specifies the maximum acceptable element count of an
   array; if m is not specified, as in the second declaration, it is
   assumed to be (2**32) - 1.

What did you expect to see?

Set the maximum value to (2**32) - 1.

What did you see instead?

The maximum value is set to (2**31) - 1.

Can you help confirm if this is a bug? Or am I missing something?

@overcat overcat added the bug label Mar 4, 2020
@bartekn
Copy link
Contributor

bartekn commented Mar 5, 2020

It looks like a bug but I think it's worth checking if arrays with a length larger than (2**31) - 1 actually work in JS. I suspect it may be due to JS limitations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants