@n3npq Could you tell me please, what am I doing wrong here?

```c
static int readPackage(const char *packageFileName)
{
    int ret = 0;

    const FD_t fd = Fopen(packageFileName, "r+.ufdio");
    if (fd == NULL || Ferror(fd)) {
        fprintf(stderr, _("%s: open failed: %s\n"), packageFileName, 
Fstrerror(fd));
        ret = 1;
        goto exit;
    }

    /* Read rpm lead */
    char *msg = NULL;
    if (rpmLeadRead(fd, NULL, &msg) != RPMRC_OK) {
        fprintf(stderr, _("Unable to read rpm lead from %s: %s\n"), 
packageFileName, msg);
        ret = 2;
        goto exit;
    }

    struct hdrblob_s sigblob;
    if (hdrblobRead(fd, 1, 0, RPMTAG_HEADERSIGNATURES, &sigblob, &msg)) {
        fprintf(stderr, _("Could not read signature header from %s: %s\n"), 
packageFileName, msg);
        ret = 3;
        goto exit;
    }

    struct hdrblob_s blob;
    if (hdrblobRead(fd, 1, 1, RPMTAG_HEADERIMMUTABLE, &blob, &msg)) {
        fprintf(stderr, _("Could not read header from %s: %s\n"), 
packageFileName, msg);
        ret = 5;
        goto exit;
    }

    Header sigh = NULL;
    if (hdrblobImport(&sigblob, 0, &sigh, &msg)) {
        fprintf(stderr, _("Could not parse signature header from %s: %s\n"), 
packageFileName, msg);
        ret = 4;
                goto exit;
    }


    Header h = NULL;
    if (hdrblobImport(&blob, 0, &h, &msg)) {
        fprintf(stderr, _("Could not parse header from %s: %s\n"), 
packageFileName, msg);
        ret = 6;
                goto exit;
    }

    if (!sigh || !h) {
        fprintf(stderr, "Pointers are null.\n");
        ret = 7;
        goto exit;
    }
    unloadImmutableRegion(h, RPMTAG_HEADERIMMUTABLE);
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/478#issuecomment-409570753
_______________________________________________
Rpm-maint mailing list
[email protected]
http://lists.rpm.org/mailman/listinfo/rpm-maint

Reply via email to