@@ -111,19 +111,12 @@ Expected<NewArchiveMember> NewArchiveMember::getFile(StringRef FileName,
111
111
}
112
112
113
113
template <typename T>
114
- static void printWithSpacePadding (raw_fd_ostream &OS, T Data, unsigned Size ,
115
- bool MayTruncate = false ) {
114
+ static void printWithSpacePadding (raw_fd_ostream &OS, T Data, unsigned Size ) {
116
115
uint64_t OldPos = OS.tell ();
117
116
OS << Data;
118
117
unsigned SizeSoFar = OS.tell () - OldPos;
119
- if (Size > SizeSoFar) {
120
- OS.indent (Size - SizeSoFar);
121
- } else if (Size < SizeSoFar) {
122
- assert (MayTruncate && " Data doesn't fit in Size" );
123
- // Some of the data this is used for (like UID) can be larger than the
124
- // space available in the archive format. Truncate in that case.
125
- OS.seek (OldPos + Size );
126
- }
118
+ assert (SizeSoFar <= Size && " Data doesn't fit in Size" );
119
+ OS.indent (Size - SizeSoFar);
127
120
}
128
121
129
122
static bool isBSDLike (object::Archive::Kind Kind) {
@@ -153,8 +146,12 @@ static void printRestOfMemberHeader(
153
146
raw_fd_ostream &Out, const sys::TimePoint<std::chrono::seconds> &ModTime,
154
147
unsigned UID, unsigned GID, unsigned Perms, unsigned Size ) {
155
148
printWithSpacePadding (Out, sys::toTimeT (ModTime), 12 );
156
- printWithSpacePadding (Out, UID, 6 , true );
157
- printWithSpacePadding (Out, GID, 6 , true );
149
+
150
+ // The format has only 6 chars for uid and gid. Truncate if the provided
151
+ // values don't fit.
152
+ printWithSpacePadding (Out, UID % 1000000 , 6 );
153
+ printWithSpacePadding (Out, GID % 1000000 , 6 );
154
+
158
155
printWithSpacePadding (Out, format (" %o" , Perms), 8 );
159
156
printWithSpacePadding (Out, Size , 10 );
160
157
Out << " `\n " ;
0 commit comments