Changeset - r9630:8b3326d306d0
[Not reviewed]
master
0 1 0
frosch - 16 years ago 2008-07-12 14:49:43
frosch@openttd.org
(svn r13693) -Fix (r11106, r11117): Do not rely on .tar files always ending with a block of zeros.
1 file changed with 4 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/fileio.cpp
Show inline comments
 
@@ -487,8 +487,10 @@ static bool TarListAddFile(const char *f
 
	char empty[512];
 
	memset(&empty[0], 0, sizeof(empty));
 

	
 
	while (!feof(f)) {
 
		pos += fread(&th, 1, 512, f);
 
	for (;;) { // Note: feof() always returns 'false' after 'fseek()'. Cool, isn't it?
 
		size_t num_bytes_read = fread(&th, 1, 512, f);
 
		if (num_bytes_read != 512) break;
 
		pos += num_bytes_read;
 

	
 
		/* Check if we have the new tar-format (ustar) or the old one (a lot of zeros after 'link' field) */
 
		if (strncmp(th.magic, "ustar", 5) != 0 && memcmp(&th.magic, &empty[0], 512 - offsetof(TarHeader, magic)) != 0) {
0 comments (0 inline, 0 general)