-
Notifications
You must be signed in to change notification settings - Fork 191
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
Upper limit of a string #817
Comments
Although I personally wouldn't make these hard restrictions even if the spec does explicitly say it (I'd rather stick to "be liberal in what you accept from others"; e.g. if I'd encounter a file with a 260-byte field when it should be at most 256, I would try to parse it anyway, regardless of whether it strictly conforms to the spec or not), sure, it's possible. You can enforce the 256-byte limit using the Note that the I see two options how to use it in your situation:
Nice thing is that neither of these approaches bother to parse the actual string from raw bytes if the BTW, any chance you're describing the format SoundFont 2.04? If so, I have almost finished a KSY spec for this format (kaitai-io/kaitai_struct_formats#293). If you're interested, let me know. |
No, I was making a parser for Microsoft CAB files, mostly for a way to figure out what Kaitai can do and is all about. I think I will go with the simpler solution you suggested where I just allow any length of string since even though the spec says a specific size, I don't see any reason to limit to that length (outside of buffer optimization purposes maybe). I put a link to the the ksy below if you want to look at it. Probably some unorthodox stuff in there. For now I'll close the issue. Thanks for the help. |
A parser for a CAB? We are waiting for it for a long time. Please register yourself in https://github.com/kaitai-io/kaitai_struct_formats and note that we have some drafts for CDF in the repo. Also please note https://github.com/kaitai-io/kaitai_compress , you will surely need it, since CAB uses custom compression algo. |
Sorry if this is answered somewhere in the docs, I can't seem to find anything that matches the exact thing I'm looking for.
I have a value that is a NULL-terminated string but can be no longer than 256 bytes (with NULL terminator included). I tried doing:
but this seems to imply that the string is 256 bytes, not that the maximum is 256 bytes. This doesn't work for me since the field size depends on where the null-terminator is or if it reaches 256 bytes.
Is there anything that can describe what I'm wanting?
EDIT: It would also work if there was maybe an error that occurred if the null-terminator was past the 256-byte mark.
The text was updated successfully, but these errors were encountered: