Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #12433

Re: Finally found it! A seekable file stream

From "R.Wieser" <address@not.available>
Newsgroups microsoft.public.scripting.vbscript
Subject Re: Finally found it! A seekable file stream
Date 2022-03-09 16:58 +0100
Organization Aioe.org NNTP Server
Message-ID <t0aisl$83u$1@gioia.aioe.org> (permalink)
References <8yrub5dio333.di58abv72sye$.dlg@40tude.net> <t0ac1b$bcp$1@dont-email.me>

Show all headers | View raw


Mayayana,

> For example, ...  if you use ReadAll it will be snipped at
> the first null.

Not quite.   Have you ever looked at the last series of bytes in both the 
actual file are the resulting "readall" buffer ?  They match.

Also, up until a certain number of bytes embedded NUL chars *and their 
following data* will be kept as you have provided it.

The problem is that "readall" reads the file in chunks. When the current 
buffer overflows a new buffer is allocated the size of the old one + the 
size of a chunk, and copies the old buffer into the new buffer.  And that 
copy method is where it goes wrong - it does a zero-terminated string copy*, 
instead of (a much simpler) block copy.

But it still it stores the new data at the correct point in that buffer - 
into the last block of it.  Hence the start *and* the end of the file 
matching the "readall" result.

* That copy method actually has got two paths, one for zero-terminated 
string, and another for binary.   My guess is therefore that someone made a 
fat-finger error - providing a True where a False should have been (or 
vice-verse).

> The WSH designers were surprisingly sloppy.

Tell me about it.  Like the dictionary object *which adds a key* when you 
ask for it to return the data of a key and the key doesn't exist yet.  It 
makes a bit of a mockery of the objects "exists" method.

The most surprising to me is that neither have been fixed ...

> I suppose that at the time it was just a seat-of-the-pants GUI
> update to DOS that they figured would only be needed by a few
> people.

It was also used as the MS script language for webpages (as a "better" 
alternative to JS).  I remember it as part of IE5 (W98).

Regards,
Rudy Wieser 

Back to microsoft.public.scripting.vbscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Finally found it! A seekable file stream JJ <jj4public@gmail.com> - 2022-03-09 13:04 +0700
  Re: Finally found it! A seekable file stream "Mayayana" <mayayana@invalid.nospam> - 2022-03-09 09:01 -0500
    Re: Finally found it! A seekable file stream "R.Wieser" <address@not.available> - 2022-03-09 16:58 +0100
      Re: Finally found it! A seekable file stream "Mayayana" <mayayana@invalid.nospam> - 2022-03-09 12:07 -0500
    Re: Finally found it! A seekable file stream JJ <jj4public@gmail.com> - 2022-03-10 12:33 +0700

csiph-web