Procházet zdrojové kódy

libdpkg: update w_booleandefno() to cope with the changed type of booleans

Boolean fields are now stored in "bool" variables and no longer in integers.
The former is 1-byte long and doesn't match the length of an int, so the
cast done in PKGPFIELD was reading too much data after the offset where
the boolean field is stored.

This update was missed in commit 7eb30624a0b7955924bafd9466d226f70e5cf48f.
Raphaël Hertzog před 16 roky
rodič
revize
e6f6bb08f1
1 změnil soubory, kde provedl 4 přidání a 3 odebrání
  1. 4 3
      lib/dpkg/dump.c

+ 4 - 3
lib/dpkg/dump.c

@@ -33,6 +33,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 
 #include <dpkg/i18n.h>
 #include <dpkg/dpkg.h>
@@ -138,13 +139,13 @@ void w_filecharf(struct varbuf *vb,
 void w_booleandefno(struct varbuf *vb,
                     const struct pkginfo *pigp, const struct pkginfoperfile *pifp,
                     enum fwriteflags flags, const struct fieldinfo *fip) {
-  int value= pifp->valid ? PKGPFIELD(pifp,fip->integer,int) : -1;
+  bool value = pifp->valid ? PKGPFIELD(pifp, fip->integer, bool) : false;
   if (!(flags&fw_printheader)) {
-    varbufaddstr(vb, (value==1) ? "yes" : "no");
+    varbufaddstr(vb, value ? "yes" : "no");
     return;
   }
   if (!value) return;
-  assert(value==1);
+  assert(value == true);
   varbufaddstr(vb,fip->name); varbufaddstr(vb, ": yes\n"); 
 }