[aklug] XDR notation question

From: David M. Syzdek <david@syzdek.net>
Date: Mon Feb 14 2011 - 13:10:02 AKST

Hi Guys,
I have a pseudo programming question for the hackers on the list. I am
trying to describe a file format using XDR notation. The files have
variable sizes and may potentially exceed 4GB in size. I'm running into
size limitations of XDR since it uses 32bit fields for datatypes with
dynamic length (array, string, and opaque). Suppose the following
simplified XDR struct which contains an opaque datatype with a dynamic size:

struct {

   unsigned int magicID;

   unsigned hyper contentSize;

   opaque content<>;

} fileFormat;

The struct member `content' is limited to 4GB in size. This is because the
length of an array, string, or opaque is specified with a four byte field
immediately preceding the data. In the case of opaque and string datatypes,
this causes the data to be limited to 4GB. According to the documentation
the following declares a fixed length opaque (the same is true for strings
and arrays):

 struct {

   unsigned int magicID;

   unsigned hyper contentSize;

   opaque content[0x140000000];

} fileFormat;

Since the standard does not specify a width for the value used to indicate
the length of a fixed length array, string, and opaque, it is theoretically
possible to declare an opaque which contains 5GB of data, such as the one
above. According to the XDR standard, the use of constants is permitted to
declare the length of an array, string, or opaque:

const MAXSIZE 0x140000000;

struct {

   unsigned int magicID;

   unsigned hyper contentSize;

   opaque content[MAXSIZE];

} fileFormat;

Since the datatype `unsigned hyper' is a 64 bit length field, is it
legitimate to use the following notation to allow an opaque to contain more
than 4GB of data such as in the following example?

 struct {

   unsigned int magicID;

   unsigned hyper contentSize;

   opaque content[contentSize];

} fileFormat;

I am trying not to abuse XDR by twisting its use into something it is not,
however I am trying to very simply describe the contents of a file which
will be on the order of 5GB - 16GB in size (possibly higher).

Thank you for any insights you may have.

--David Syzdek

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Mon Feb 14 13:10:11 2011

This archive was generated by hypermail 2.1.8 : Mon Feb 14 2011 - 13:10:11 AKST