summaryrefslogtreecommitdiff
path: root/lib/rpmlead.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2002-08-05 19:45:52 +0000
committerjbj <devnull@localhost>2002-08-05 19:45:52 +0000
commitbd5ee7affaa5f350c03fba20952b7a16e1311c4e (patch)
tree95c72df38e38afd76f9d5b8329a839d8b05335f0 /lib/rpmlead.c
parentb8656c52ed8d856e0b744f35488b3c5ec0b023e8 (diff)
downloadlibrpm-tizen-bd5ee7affaa5f350c03fba20952b7a16e1311c4e.tar.gz
librpm-tizen-bd5ee7affaa5f350c03fba20952b7a16e1311c4e.tar.bz2
librpm-tizen-bd5ee7affaa5f350c03fba20952b7a16e1311c4e.zip
- fix: check for lead magic, better error message on failure (#69751).
CVS patchset: 5602 CVS date: 2002/08/05 19:45:52
Diffstat (limited to 'lib/rpmlead.c')
-rw-r--r--lib/rpmlead.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/rpmlead.c b/lib/rpmlead.c
index 6d4efa62a..be0b24944 100644
--- a/lib/rpmlead.c
+++ b/lib/rpmlead.c
@@ -15,6 +15,10 @@
#include "rpmlead.h"
#include "debug.h"
+static unsigned char lead_magic[] = {
+ RPMLEAD_MAGIC0, RPMLEAD_MAGIC1, RPMLEAD_MAGIC2, RPMLEAD_MAGIC3
+};
+
/* The lead needs to be 8 byte aligned */
int writeLead(FD_t fd, const struct rpmlead *lead)
@@ -25,11 +29,7 @@ int writeLead(FD_t fd, const struct rpmlead *lead)
memcpy(&l, lead, sizeof(*lead));
/*@=boundswrite@*/
- l.magic[0] = RPMLEAD_MAGIC0;
- l.magic[1] = RPMLEAD_MAGIC1;
- l.magic[2] = RPMLEAD_MAGIC2;
- l.magic[3] = RPMLEAD_MAGIC3;
-
+ memcpy(&l.magic, lead_magic, sizeof(lead_magic));
l.type = htons(l.type);
l.archnum = htons(l.archnum);
l.osnum = htons(l.osnum);
@@ -56,6 +56,9 @@ int readLead(FD_t fd, struct rpmlead *lead)
}
/*@=type@*/
+ if (memcmp(lead->magic, lead_magic, sizeof(lead_magic)))
+ return 1;
+
lead->type = ntohs(lead->type);
lead->archnum = ntohs(lead->archnum);
lead->osnum = ntohs(lead->osnum);