Преглед изворни кода

dpkg-deb: Force the ar member name to 16 space padded chars wide

This makes the code resilient to changes to the member name strings
and guarantees it will always have the valid length, also makes it
easier to refactor later on.
Guillem Jover пре 16 година
родитељ
комит
3fe6efee7d
1 измењених фајлова са 5 додато и 3 уклоњено
  1. 5 3
      dpkg-deb/build.c

+ 5 - 3
dpkg-deb/build.c

@@ -448,13 +448,15 @@ void do_build(const char *const *argv) {
     thetime = time(NULL);
     thetime = time(NULL);
     if (fprintf(ar,
     if (fprintf(ar,
                 "!<arch>\n"
                 "!<arch>\n"
-                DEBMAGIC "%-12lu0     0     100644  %-10ld`\n"
+                "%-16s%-12lu0     0     100644  %-10ld`\n"
                 ARCHIVEVERSION "\n"
                 ARCHIVEVERSION "\n"
                 "%s"
                 "%s"
-                ADMINMEMBER "%-12lu0     0     100644  %-10ld`\n",
+                "%-16s%-12lu0     0     100644  %-10ld`\n",
+                DEBMAGIC,
                 thetime,
                 thetime,
                 (long)sizeof(ARCHIVEVERSION),
                 (long)sizeof(ARCHIVEVERSION),
                 (sizeof(ARCHIVEVERSION)&1) ? "\n" : "",
                 (sizeof(ARCHIVEVERSION)&1) ? "\n" : "",
+                ADMINMEMBER,
                 (unsigned long)thetime,
                 (unsigned long)thetime,
                 (long)controlstab.st_size) == EOF)
                 (long)controlstab.st_size) == EOF)
       werr(debar);
       werr(debar);
@@ -557,7 +559,7 @@ void do_build(const char *const *argv) {
       ohshite(_("failed to fstat tmpfile (data)"));
       ohshite(_("failed to fstat tmpfile (data)"));
     if (fprintf(ar,
     if (fprintf(ar,
                 "%s"
                 "%s"
-                "%s" "%-12lu0     0     100644  %-10ld`\n",
+                "%-16s%-12lu0     0     100644  %-10ld`\n",
                 (controlstab.st_size & 1) ? "\n" : "",
                 (controlstab.st_size & 1) ? "\n" : "",
                 datamember,
                 datamember,
                 (unsigned long)thetime,
                 (unsigned long)thetime,