I am just starting to dig into the DCS SDK and these two pages caught my eye.

http://dcs.cemetech.net/index.php/BasicLibs:BinRead

http://dcs.cemetech.net/index.php/BasicLibs:BinDelete

BinRead takes data from a "FILENAME", I assume that only means .8xp filenames since it didn't work with an appvar name. I am wondering why it allows negative values for the start byte and allows the arguments to go past the end of the file. It's not too important since security isn't a concern on a calculator, but there all kinds of weird things that this entails, which I'll describe in a second. BinDelete is worse, again it allows negative arguments and it can will accept arguments that make go past the end of the file, which is an actual problem since this means you can crash the calculator very easily, as I did.

The weird things I mentioned earlier:

1. Since you can give BinRead nonsensical arguments, I tried 10^96, 10^97 etc, with various arguments for the length. They all returned the same predefined section of a string only varying based on the length argument.

2. They accept non-integer arguments for the starting byte and the length of the returned string. For BinRead with 0 as the start byte, and .999 for the length, I got a memory error. For .599 as the length I got a long stream of flowing tokens and ASCII before it crashed.

3. For a nonexistent program file, BinRead writes ".7" to ANS and ".6" for a blank string as the filename, which isn't on the SDK page.

4. From BinRead I have gotten ".L" when I gave the imaginary unit as the argument for the start byte, and 1, for the length.

5. For BinRead and BinDelete, I gave i, the imaginary unit as the arguments for the start byte and the number of bytes and it archived the program I gave as the filename.

I could go on, but I think this is enough.

http://dcs.cemetech.net is formatted like a wiki, but I can't seem to find anyway to edit. What I would like to do is dive into the DCS source code help document it, since all of the pages seem pretty sparce.

If anyone can explain why these "functions" act so weirdly instead of just giving error messages, I would love to hear it. Otherwise I'd like to ask if there is a way to edit pages on http://dcs.cemetech.net
Deoxal1 wrote:
I am just starting to dig into the DCS SDK and these two pages caught my eye.

http://dcs.cemetech.net/index.php/BasicLibs:BinRead

http://dcs.cemetech.net/index.php/BasicLibs:BinDelete

BinRead takes data from a "FILENAME", I assume that only means .8xp filenames since it didn't work with an appvar name.
Incorrect. Via the parent page:
Quote:
To use an AppVar instead of a program as input, prepend the string with the "rowSwap(" token.

Deoxal1 wrote:
I am wondering why it allows negative values for the start byte and allows the arguments to go past the end of the file. It's not too important since security isn't a concern on a calculator, but there all kinds of weird things that this entails, which I'll describe in a second. BinDelete is worse, again it allows negative arguments and it can will accept arguments that make go past the end of the file, which is an actual problem since this means you can crash the calculator very easily, as I did.
It's the programmer's responsibility to provide sane arguments here; some safety checks are performed, but others are not to give programmers more flexibility.

Quote:
The weird things I mentioned earlier:

1. Since you can give BinRead nonsensical arguments, I tried 10^96, 10^97 etc, with various arguments for the length. They all returned the same predefined section of a string only varying based on the length argument.

2. They accept non-integer arguments for the starting byte and the length of the returned string. For BinRead with 0 as the start byte, and .999 for the length, I got a memory error. For .599 as the length I got a long stream of flowing tokens and ASCII before it crashed.
Welcome to dumping random memory. Wink

Quote:
3. For a nonexistent program file, BinRead writes ".7" to ANS and ".6" for a blank string as the filename, which isn't on the SDK page.

4. From BinRead I have gotten ".L" when I gave the imaginary unit as the argument for the start byte, and 1, for the length.
These are error codes. See the original Celtic 3 documentation for the definitions of these "short" error codes. You can get the long error codes from the output string.

Quote:
I could go on, but I think this is enough.
Fun! I consider none of these bug reports, but it's an interesting investigation into what these functions do with invalid arguments.

Quote:
http://dcs.cemetech.net is formatted like a wiki, but I can't seem to find anyway to edit. What I would like to do is dive into the DCS source code help document it, since all of the pages seem pretty sparse.
Unless Tari disconnected it, it's linked to Cemetech user credentials, so you should be able to log in with those.
Okay, thanks for the clarification Kerm. I disagree that it is the job of the programmer who is making a mobile app etc to do input validation though. If that were the case for computer programming then it would be much easier to write exploits and steal personal info from people. Since that's not a concern here, I think it makes sense to have safety checks at least for BinDelete since you can easily crash the calculator.

Do you have an explanation for #5 though, I didn't see anything about archival in the other libraries, but maybe I just need to look harder?

BTW I'm enjoying your book right now. (:
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement