gpgme_op_decrypt segfault

Ingo Klöcker kloecker at kde.org
Tue Jun 29 09:20:19 CEST 2021


Hi,

On Montag, 28. Juni 2021 21:37:58 CEST Schultschik, Sven via Gnupg-users 
wrote:
> Hello all together,
> 
> I have created a small Applikation to zip and encrypte and vise versa.
> 
> I struggle at the point of          err = gpgme_op_decrypt(ctx, in, out);
> Which terminates with an segfault if not sufficient access rights are
> available. If I run with sudo it works as expected.

It would be really helpful if you'd give us the backtrace you get for the 
segfault.

Moreover, it is unclear what you mean by "not sufficient access rights are 
available". Is the input file only readable by root? Or is only root allowed 
to write to fullBackupPath?

Quite frankly, it's up to you, the caller/user of gpgme, to check whether the 
fopen() calls succeeded before you pass the streams to gpgme. You do check 
instream for being NULL, but apparently you forgot to check outstream. Should 
gpgme_data_new_from_stream() check for a null pointer passed to it? Maybe. 
Should you pass a NULL pointer to gpgme_data_new_from_stream()? Definitely 
not. It makes no sense because how should gpgme_data_new_from_stream() know 
the reason for the NULL pointer?

FWIW, I just checked. gpgme_data_new_from_stream() does not check for a NULL 
pointer. I guess this could be changed.

Regards,
Ingo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20210629/f774e863/attachment-0001.sig>


More information about the Gnupg-users mailing list