From: Adam Heath Date: Sun, 26 May 2002 06:40:41 +0000 (+0000) Subject: dpkg now reorders symlinks when extracting debs. However, this is also X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb088cf4d1696832b90c5ba6845087e33bcdaaff;p=dpkg dpkg now reorders symlinks when extracting debs. However, this is also still done when building debs. After a stable release of Debian has occurred with this modified dpkg, the reordering when building can be removed. --- diff --git a/ChangeLog b/ChangeLog index 14d56069..47844432 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun May 26 01:35:34 CDT 2002 Adam Heath + + * lib/tarfn.c: dpkg now reorders symlinks when extracting debs. However, + this is also still done when building debs. After a stable release of + Debian has occurred with this modified dpkg, the reordering when + building can be removed. + Sun May 26 01:28:00 CDT 2002 Adam Heath * debian/dpkg.postinst: Fix /usr/info/dir moving/symlink code. diff --git a/debian/changelog b/debian/changelog index 114b634f..a1740b15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,9 @@ dpkg (1.10) unstable; urgency=low + * dpkg now reorders symlinks when extracting debs. However, this is also + still done when building debs. After a stable release of Debian has + occurred with this modified dpkg, the reordering when building can be + removed. * Fixed upper/lowercase problems with package names. Closes: Bug#58091 (and 3 others). * Add Russian manual pages diff --git a/lib/tarfn.c b/lib/tarfn.c index c1a5ee93..6752f2b5 100644 --- a/lib/tarfn.c +++ b/lib/tarfn.c @@ -97,6 +97,11 @@ DecodeTarHeader(char * block, TarInfo * d) return ( sum == checksum ); } +typedef struct symlinkList { + TarInfo h; + struct symlinkList *next; +} symlinkList; + extern int TarExtractor( void * userData @@ -110,10 +115,13 @@ TarExtractor( char *bp; char **longp; int long_read; + symlinkList *symListTop, *symListBottom, *symListPointer; next_long_name = NULL; next_long_link = NULL; long_read = 0; + symListBottom = symListPointer = symListTop = malloc(sizeof(symlinkList)); + symListTop->next = NULL; h.UserData = userData; @@ -122,11 +130,12 @@ TarExtractor( if ( !DecodeTarHeader(buffer, &h) ) { if ( h.Name[0] == '\0' ) { - return 0; /* End of tape */ + status = 0; /* End of tape */ } else { errno = 0; /* Indicates broken tarfile */ - return -1; /* Header checksum error */ + status = -1; /* Header checksum error */ } + break; } if (next_long_name) { h.Name = next_long_name; @@ -141,7 +150,8 @@ TarExtractor( if ( h.Name[0] == '\0' ) { errno = 0; /* Indicates broken tarfile */ - return -1; /* Bad header data */ + status = -1; /* Bad header data */ + break; } nameLength = strlen(h.Name); @@ -163,7 +173,28 @@ TarExtractor( status = (*functions->MakeHardLink)(&h); break; case SymbolicLink: - status = (*functions->MakeSymbolicLink)(&h); + memcpy(&symListBottom->h, &h, sizeof(TarInfo)); + if ((symListBottom->h.Name = strdup(h.Name)) == NULL) { + status = -1; + errno = 0; + break; + } + if ((symListBottom->h.LinkName = strdup(h.LinkName)) == NULL) { + free(symListBottom->h.Name); + status = -1; + errno = 0; + break; + } + if ((symListBottom->next = malloc(sizeof(symlinkList))) == NULL) { + free(symListBottom->h.LinkName); + free(symListBottom->h.Name); + status = -1; + errno = 0; + break; + } + symListBottom = symListBottom->next; + symListBottom->next = NULL; + status = 0; break; case CharacterDevice: case BlockDevice: @@ -184,7 +215,8 @@ TarExtractor( if (NULL == (*longp = (char *)malloc(h.Size))) { /* malloc failed, so bail */ errno = 0; - return -1; + status = -1; + break; } bp = *longp; @@ -203,10 +235,9 @@ TarExtractor( if (512 != status) { if ( status > 0 ) { /* Read partial header record */ errno = 0; - return -1; - } else { - return status; + status = -1; } + break; } copysize = long_read > 512 ? 512 : long_read; @@ -221,10 +252,19 @@ TarExtractor( break; default: errno = 0; /* Indicates broken tarfile */ - return -1; /* Bad header field */ + status = -1; /* Bad header field */ } if ( status != 0 ) - return status; /* Pass on status from coroutine */ + break; /* Pass on status from coroutine */ + } + while(symListPointer->next) { + if ( status == 0 ) + status = (*functions->MakeSymbolicLink)(&symListPointer->h); + symListBottom = symListPointer->next; + free(symListPointer->h.Name); + free(symListPointer->h.LinkName); + free(symListPointer); + symListPointer = symListBottom; } if ( status > 0 ) { /* Read partial header record */ errno = 0; /* Indicates broken tarfile */ @@ -233,3 +273,4 @@ TarExtractor( return status; /* Whatever I/O function returned */ } } +