Re: What are SZ array?
- From: "Tom Dacon" <tdacon@xxxxxxxxxxxxxxxx>
- Date: Mon, 30 Jun 2008 10:14:59 -0700
I see from your follow-up post that the original author uses a different
meaning altogether for the term 'SZ array', so you may disregard my
explanation of a much different meaning of the term.
Tom Dacon
Dacon Software Consulting
"Tom Dacon" <tdacon@xxxxxxxxxxxxxxxx> wrote in message
news:e%23a2SQt2IHA.5512@xxxxxxxxxxxxxxxxxxxxxxx
This is probably referring to the way that strings were represented in C
and C++, before Unicode and other languages such as VB came along.
Strings, in those days and those languages, were maintained in memory as
one-dimensional arrays of bytes, with each byte containing a character (or
'char'). The characters in the string were followed by a single byte with
a value of binary zero. This was also called a 'null byte', and one might
say of such a string that it was 'null-terminated'.
The byte array (or char array) was allocated at fixed length (the
'character buffer') and the byte or character count included space for the
terminating null character. So a string variable could contain any number
of characters, including zero characters, up to the length of the buffer
minus one, because the null-terminating character had to be there to
satisfy the C/C++ runtime code. The C and C++ runtime understood this
convention, and the programmer had to as well, so as to always allocate
string variables with enough space to contain the terminating null
character.
This convention has become one of the most popular attack vectors for
hacking - the "buffer overflow" that you always are hearing about -
because it's easy to store into one of those byte arrays a string that's
longer than the size of the array, and programmers are typically negligent
about checking that an input string is not too large to store into the
space allocated.
In Microsoft's ghastly old Hungarian notation - invented by Charles
Simonyi and badly misused by Microsoft programmers for a long time
afterwards - it was common to prefix the name of a string variable with
the characters 'sz' (meaning 'zero-terminated string').
This is still supported in Microsoft's C and C++ languages.
Tom Dacon
Dacon Software Consulting
Jon Skeet will be along in a minute to correct my account of this, so
don't consider this question answered until he has weighed in on the issue
:-)
<qglyirnyfgfo@xxxxxxxxxxxxxx> wrote in message
news:00fb2d18-0f8a-4d5b-866c-c6c4689f5fb4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I was reading an article regarding .Net arrays and on that article,
the author mentioned something about SZ arrays.
As far as I can tell, SZ arrays are one dimension arrays that are zero
based, am I correct on this? Also, can someone tell me what does "SZ"
stands for?
Thank you.
.
- Follow-Ups:
- Re: What are SZ array?
- From: qglyirnyfgfo
- Re: What are SZ array?
- References:
- What are SZ array?
- From: qglyirnyfgfo
- Re: What are SZ array?
- From: Tom Dacon
- What are SZ array?
- Prev by Date: Re: What are SZ array?
- Next by Date: DataGridViewColumns .NET 2.0 by RustemSoft.
- Previous by thread: Re: What are SZ array?
- Next by thread: Re: What are SZ array?
- Index(es):
Relevant Pages
|