Page MenuHome GnuPG

gpg returns "unknown system error" when given an empty file
Open, NormalPublic

Description

gpg <path/to/file> does return the vague error message "unknown system error" if the given file is empty. this is neither a system error, nor should the problem be considered "unknown".

gpg should rather return something helpful the likes of "no content".

this was mentioned in the forum for windows and i was able to replicate it on linux with version 2.5.12:

$ touch test.gpg
$ gpg test.gpg
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: processing message failed: Unknown system error

Details

Version
2.5.12

Event Timeline

werner triaged this task as Normal priority.Fri, Oct 10, 2:04 PM
werner added a project: Bug Report.
werner added a subscriber: werner.

The problem here is that iobuf_readbyte returns -1 on error and on EOF. parse_packet is not able to distinguish that because for histroic reasons we do not return a gpg-error code (GPG_ERR_EOF). To fix this we need to change all callers of parse_packet to not act upon -1 but only on an error code.

/* FIXME: We use only the error code for now to avoid problems with
    callers which have not been checked to always use gpg_err_code()
    when comparing error codes.  */
 return rc == -1? -1 : gpg_err_code (rc);

}