From: root Date: Wed, 14 Feb 1996 17:55:28 +0000 (+0000) Subject: added support for old packages, lots of bug fixes X-Git-Tag: tznext/4.11.0.1.tizen20130304~11695 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ca4a7f8132ecb5444b0988c8c46e9dd8a8b4eeef;p=tools%2Flibrpm-tizen.git added support for old packages, lots of bug fixes CVS patchset: 265 CVS date: 1996/02/14 17:55:28 --- diff --git a/lib/rpmlead.c b/lib/rpmlead.c index be211aa..2a5f2fd 100644 --- a/lib/rpmlead.c +++ b/lib/rpmlead.c @@ -1,8 +1,9 @@ +#include #include #include #include -#include +#include "rpmerr.h" #include "rpmlead.h" int writeLead(int fd, struct rpmlead *lead) @@ -28,12 +29,18 @@ int writeLead(int fd, struct rpmlead *lead) int readLead(int fd, struct rpmlead *lead) { - read(fd, lead, sizeof(*lead)); + if (read(fd, lead, sizeof(*lead)) != sizeof(*lead)) { + error(RPMERR_READERROR, "read failed: %s (%d)", strerror(errno), + errno); + return 1; + } lead->type = ntohs(lead->type); lead->archnum = ntohs(lead->archnum); lead->osnum = ntohs(lead->osnum); - lead->signature_type = ntohs(lead->signature_type); + + if (lead->major >= 2) + lead->signature_type = ntohs(lead->signature_type); return 0; } diff --git a/lib/rpmlead.h b/lib/rpmlead.h index 62bd3c4..eadd16c 100644 --- a/lib/rpmlead.h +++ b/lib/rpmlead.h @@ -25,6 +25,17 @@ struct rpmlead { char reserved[16]; /* pads to 96 bytes -- 8 byte aligned! */ } ; +struct oldrpmlead { /* for version 1 packages */ + unsigned char magic[4]; + unsigned char major, minor; + short type; + short archnum; + char name[66]; + unsigned long specOffset; + unsigned long specLength; + unsigned long archiveOffset; +} ; + int writeLead(int fd, struct rpmlead *lead); int readLead(int fd, struct rpmlead *lead);