|
Post by rstevens on Mar 7, 2005 12:35:29 GMT -5
I'm receiving a stream over a WinSocket. If these come from a valid user they will be a zipped stream. If the user is not valid, i.e someone tries to send miscellaneous characters to the port, how can I check that the stream is a valid stream that can be UnZipped? Hope the question makes sense. If not, let me know and I'll try again...
|
|
|
Post by Kevin on Mar 8, 2005 7:52:42 GMT -5
If you are a registered user, check KPZIPOBJ.PAS and you will see some definitions for headers. A zip file will start with a local header and that local header will start with a particular signature. You could check for that signature.
Kevin
|
|
|
Post by rstevens on Mar 8, 2005 11:15:50 GMT -5
Is this the header record??
local_file_header = packed record Signature: SignatureType; version_needed_to_extract: WORD; general_purpose_bit_flag: WORD; compression_method: WORD; last_mod_file_date_time: U_LONG; crc32: U_LONG; compressed_size: LongInt; uncompressed_size: LongInt; filename_length: WORD; extra_field_length: WORD; end;
and if so, how would I test it??
Thanks for your help Kevin
|
|
|
Post by Kevin on Mar 8, 2005 18:41:57 GMT -5
Yes, you should test the first 4 bytes and they should be the signature. For standard zip files, this signature would be, as is defined in KPZCONST.PAS as
DEF_LOCSIG = $04034b50;
Kevin
|
|