Parcourir la source

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 il y a 16 ans
Parent
commit
e6f6bb08f1
1 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. 4 3
      lib/dpkg/dump.c

+ 4 - 3
lib/dpkg/dump.c

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