Re: What are SZ array?



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.


.



Relevant Pages

  • Re: VERY simple question about "?"
    ... don't see the equivalence between a string delimiter, or a character that signals the beginning of a symbol, and a symbol that is actually productive of something. ... Part of my difficulty understanding you is probably caused by the fact that you seem to try to tackle problems of computer languages with tools from a complete different domain. ... "Tom" - my name can also be called, but when one does so IT doesn't spring into action at all. ...
    (comp.lang.ruby)
  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)

Loading