Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 2008 17:11:34 GMT
From:      Anselm Strauss <strauss@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 147314 for review
Message-ID:  <200808131711.m7DHBY5b077782@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=147314

Change 147314 by strauss@strauss_marvelman on 2008/08/13 17:11:22

	Corrected the format of extra data in the central directory (is different from the same data formatted in the local header).

Affected files ...

.. //depot/projects/soc2008/strauss_libarchive/TODO#14 edit
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#34 edit

Differences ...

==== //depot/projects/soc2008/strauss_libarchive/TODO#14 (text+ko) ====

@@ -1,6 +1,8 @@
 To Be Done
 ==========
 
+- Consider portability of code to other operating systems
+- Test for memory leaks again (ask Tim)
 - Update ZIP writer in docs
 - About the keywords: of course they always change when integrating ...
 - Not all P4 keywords do expand (tested on OS X and FreeBSD)

==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#34 (text+ko) ====

@@ -121,7 +121,7 @@
 	char uncompressed_size[4];
 };
 
-struct zip_extra_data {
+struct zip_extra_data_local {
 	char time_id[2];
 	char time_size[2];
 	char time_flag[1];
@@ -134,11 +134,18 @@
 	char unix_gid[2];
 };
 
+struct zip_extra_data_central {
+	char time_id[2];
+	char time_size[2];
+	char time_flag[1];
+	char mtime[4];
+	char unix_id[2];
+	char unix_size[2];
+};
+
 struct zip_file_header_link {
 	struct zip_file_header_link *next;
 	struct archive_entry *entry;
-	char extra_length[2];
-	struct zip_extra_data extra_data;
 	off_t offset;
 	uLong crc32;
 };
@@ -204,7 +211,7 @@
 {
 	struct zip *zip;
 	struct zip_local_file_header h;
-	struct zip_extra_data e;
+	struct zip_extra_data_local e;
 	struct zip_data_descriptor *d;
 	struct zip_file_header_link *l;
 	int ret;
@@ -268,9 +275,6 @@
 	zip_encode(sizeof(e.unix_uid) + sizeof(e.unix_gid), &e.unix_size, sizeof(e.unix_size));
 	zip_encode(archive_entry_uid(entry), &e.unix_uid, sizeof(e.unix_uid));
 	zip_encode(archive_entry_gid(entry), &e.unix_gid, sizeof(e.unix_gid));
-	l->extra_data = e;
-	l->extra_length[0] = h.extra_length[0];
-	l->extra_length[1] = h.extra_length[1];
 	
 	/* This will surely change when compression is implemented. */
 	zip_encode(size, &d->compressed_size, sizeof(d->compressed_size));
@@ -338,6 +342,7 @@
 	struct zip_file_header_link *l;
 	struct zip_file_header h;
 	struct zip_central_directory_end end;
+	struct zip_extra_data_central e;
 	int64_t size;
 	off_t offset_start, offset_end;
 	int entries;
@@ -363,22 +368,29 @@
 	
 	entries = 0;
 	offset_start = zip->written_bytes;
+	
+	/* Formatting individual header fields per entry. */
 	while (l != NULL) {
 		
-		/* Formatting individual header fields per entry. */
 		size = archive_entry_size(l->entry);
 		zip_encode(dos_time(archive_entry_mtime(l->entry)), &h.timedate, sizeof(h.timedate));
 		zip_encode(l->crc32, &h.crc32, sizeof(h.crc32));
 		zip_encode(size, &h.compressed_size, sizeof(h.compressed_size));
 		zip_encode(size, &h.uncompressed_size, sizeof(h.uncompressed_size));
 		zip_encode(path_length(l->entry), &h.filename_length, sizeof(h.filename_length));
-		archive_entry_mode(l->entry);
-		h.extra_length[0] = l->extra_length[0];
-		h.extra_length[1] = l->extra_length[1];
+		zip_encode(sizeof(e), &h.extra_length, sizeof(h.extra_length));
 		mode = archive_entry_mode(l->entry);
 		zip_encode(mode, &h.attributes_external[2], sizeof(mode));
 		zip_encode(l->offset, &h.offset, sizeof(h.offset));
 		
+		/* Formatting extra data. */
+		zip_encode(ZIP_SIGNATURE_EXTRA_TIMESTAMP, &e.time_id, sizeof(e.time_id));
+		zip_encode(sizeof(e.mtime) + sizeof(e.time_flag), &e.time_size, sizeof(e.time_size));
+		zip_encode(0x07, &e.time_flag, sizeof(e.time_flag));
+		zip_encode(archive_entry_mtime(l->entry), &e.mtime, sizeof(e.mtime));
+		zip_encode(ZIP_SIGNATURE_EXTRA_UNIX, &e.unix_id, sizeof(e.unix_id));
+		zip_encode(0x0000, &e.unix_size, sizeof(e.unix_size));
+		
 		ret = (a->compressor.write)(a, &h, sizeof(h));
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
@@ -389,10 +401,10 @@
 			return (ARCHIVE_FATAL);
 		zip->written_bytes += ret;
 		
-		ret = (a->compressor.write)(a, &l->extra_data, sizeof(l->extra_data));
+		ret = (a->compressor.write)(a, &e, sizeof(e));
 		if (ret != ARCHIVE_OK)
 			return (ARCHIVE_FATAL);
-		zip->written_bytes += sizeof(l->extra_data);
+		zip->written_bytes += sizeof(e);
 		
 		l = l->next;
 		entries++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808131711.m7DHBY5b077782>