Commit c705fc67 authored by Bernhard Link's avatar Bernhard Link

decide which filename to show in errors when reading signed data

parent b8359213
......@@ -275,7 +275,8 @@ static retvalue changes_read(const char *filename,/*@out@*/struct changes **chan
c = calloc(1,sizeof(struct changes));
if( c == NULL )
return RET_ERROR_OOM;
r = signature_readsignedchunk(filename,&c->control,&c->fingerprints, NULL, &broken);
r = signature_readsignedchunk(filename, filename,
&c->control, &c->fingerprints, NULL, &broken);
R;
if( broken && !IGNORING_(brokensignatures,
"'%s' contains only broken signatures.\n"
......
......@@ -218,12 +218,14 @@ retvalue signature_check(const char *options, const char *releasegpg, const char
return RET_OK;
case GPG_ERR_SIG_EXPIRED:
if( verbose > 0 ) {
time_t timestamp = s->timestamp,
exp_timestamp = s->exp_timestamp;
fprintf(stderr,
"'%s' has a valid but expired signature with '%s'\n"
" signature created %s, expired %s\n",
releasegpg, s->fpr,
ctime(&s->timestamp),
ctime(&s->exp_timestamp));
ctime(&timestamp),
ctime(&exp_timestamp));
}
// not accepted:
continue;
......@@ -472,12 +474,14 @@ static retvalue checksigs(const char *filename, struct strlist *valid, struct st
case GPG_ERR_SIG_EXPIRED:
had_valid = TRUE;
if( verbose > 0 ) {
time_t timestamp = s->timestamp,
exp_timestamp = s->exp_timestamp;
fprintf(stderr,
"Ignoring signature with '%s' on '%s', as the signature has expired.\n"
" signature created %s, expired %s\n",
s->fpr, filename,
ctime(&s->timestamp),
ctime(&s->exp_timestamp));
ctime(&timestamp),
ctime(&exp_timestamp));
}
continue;
case GPG_ERR_BAD_SIGNATURE:
......@@ -519,7 +523,7 @@ static retvalue checksigs(const char *filename, struct strlist *valid, struct st
}
/* Read a single chunk from a file, that may be signed. */
retvalue signature_readsignedchunk(const char *filename, char **chunkread, /*@null@*/ /*@out@*/struct strlist *validkeys, /*@null@*/ /*@out@*/ struct strlist *allkeys, bool_t *brokensignature) {
retvalue signature_readsignedchunk(const char *filename, const char *filenametoshow, char **chunkread, /*@null@*/ /*@out@*/struct strlist *validkeys, /*@null@*/ /*@out@*/ struct strlist *allkeys, bool_t *brokensignature) {
const char *startofchanges,*endofchanges,*afterchanges;
char *chunk;
gpgme_error_t err;
......@@ -578,7 +582,7 @@ retvalue signature_readsignedchunk(const char *filename, char **chunkread, /*@nu
"While it did so in a way indicating running out of memory, experience says\n"
"this also happens when gpg returns a error code it does not understand.\n"
"To check this please try running gpg --output '%s' manually.\n",
filename, filename);
filenametoshow, filenametoshow);
return RET_ERROR_GPGME;
}
}
......@@ -594,7 +598,7 @@ retvalue signature_readsignedchunk(const char *filename, char **chunkread, /*@nu
if( (size_t)(startofchanges - plain_data) >= plain_len ) {
fprintf(stderr,
"Could only find spaces within '%s'!\n",
filename);
filenametoshow);
r = RET_ERROR;
} else
r = RET_OK;
......@@ -615,11 +619,11 @@ retvalue signature_readsignedchunk(const char *filename, char **chunkread, /*@nu
if( *afterchanges == '\0' )
fprintf(stderr,
"Unexpected \\0 character within '%s'!\n",
filename);
filenametoshow);
else
fprintf(stderr,
"Unexpected data after ending empty line in '%s'!\n",
filename);
filenametoshow);
r = RET_ERROR;
}
}
......
......@@ -14,7 +14,7 @@ retvalue signature_check(const char *options, const char *releasegpg, const char
retvalue signature_sign(const char *options, const char *filename, const char *signeturename);
/* Read a single chunk from a file, that may be signed. */
retvalue signature_readsignedchunk(const char *filename, char **chunkread, /*@null@*/ /*@out@*/struct strlist *validkeys, /*@null@*/ /*@out@*/ struct strlist *allkeys, bool_t *brokensignature);
retvalue signature_readsignedchunk(const char *filename, const char *filenametoshow, char **chunkread, /*@null@*/ /*@out@*/struct strlist *validkeys, /*@null@*/ /*@out@*/ struct strlist *allkeys, bool_t *brokensignature);
struct signedfile;
......
......@@ -464,7 +464,7 @@ static inline retvalue getvalue_n(const char *chunk,const char *field,char **val
retvalue sources_readdsc(struct dsc_headers *dsc, const char *filename, bool_t *broken) {
retvalue r;
r = signature_readsignedchunk(filename,&dsc->control,NULL,NULL, broken);
r = signature_readsignedchunk(filename, filename, &dsc->control, NULL, NULL, broken);
if( RET_WAS_ERROR(r) ) {
return r;
}
......
......@@ -485,7 +485,7 @@ static retvalue read_dscfile(const char *fullfilename, struct dscfile **dsc) {
n = calloc(1,sizeof(struct dscfile));
if( n == NULL )
return RET_ERROR_OOM;
r = signature_readsignedchunk(fullfilename,
r = signature_readsignedchunk(fullfilename, fullfilename,
&n->controlchunk, &n->validkeys, &n->keys, NULL);
assert( r != RET_NOTHING );
// TODO: can this be ignored sometimes?
......@@ -2427,7 +2427,8 @@ int main(int argc,char *argv[]) {
if( file_exists ) {
char *changes;
r = signature_readsignedchunk(changesfilename, &changes, &validkeys, &keys, NULL);
r = signature_readsignedchunk(changesfilename, changesfilename,
&changes, &validkeys, &keys, NULL);
if( !RET_IS_OK(r) ) {
signatures_done();
if( r == RET_ERROR_OOM )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment