Fix some issues found by 'infer'

This commit is contained in:
Tim Rühsen 2018-03-14 14:43:35 +01:00
parent 0b54043d17
commit f56f970bc2
2 changed files with 10 additions and 15 deletions

View File

@ -57,7 +57,7 @@ as that of the covered work. */
uerr_t uerr_t
ftp_response (int fd, char **ret_line) ftp_response (int fd, char **ret_line)
{ {
while (1) for (;;)
{ {
char *p; char *p;
char *line = fd_read_line (fd); char *line = fd_read_line (fd);
@ -65,12 +65,9 @@ ftp_response (int fd, char **ret_line)
return FTPRERR; return FTPRERR;
/* Strip trailing CRLF before printing the line, so that /* Strip trailing CRLF before printing the line, so that
quotting doesn't include bogus \012 and \015. */ quoting doesn't include bogus \012 and \015. */
p = strchr (line, '\0'); if ((p = strpbrk(line , "\r\n")))
if (p > line && p[-1] == '\n') *p = 0;
*--p = '\0';
if (p > line && p[-1] == '\r')
*--p = '\0';
if (opt.server_response) if (opt.server_response)
logprintf (LOG_NOTQUIET, "%s\n", logprintf (LOG_NOTQUIET, "%s\n",

View File

@ -99,8 +99,8 @@ retrieve_from_metalink (const metalink_t* metalink)
metalink_resource_t **mres_ptr; metalink_resource_t **mres_ptr;
char *planname = NULL; char *planname = NULL;
char *trsrname = NULL; char *trsrname = NULL;
char *filename = NULL; char *filename;
char *basename = NULL; char *basename;
char *safename = NULL; char *safename = NULL;
char *destname = NULL; char *destname = NULL;
bool size_ok = false; bool size_ok = false;
@ -709,8 +709,7 @@ retrieve_from_metalink (const metalink_t* metalink)
gpgme_data_t gpgsigdata, gpgdata; gpgme_data_t gpgsigdata, gpgdata;
gpgme_verify_result_t gpgres; gpgme_verify_result_t gpgres;
gpgme_signature_t gpgsig; gpgme_signature_t gpgsig;
gpgme_protocol_t gpgprot = GPGME_PROTOCOL_UNKNOWN; int fd;
int fd = -1;
/* Initialize the library - as name suggests. */ /* Initialize the library - as name suggests. */
gpgme_check_version (NULL); gpgme_check_version (NULL);
@ -751,16 +750,15 @@ retrieve_from_metalink (const metalink_t* metalink)
msig->signature)); msig->signature));
/* Check signature type. */ /* Check signature type. */
if (!strcmp (msig->mediatype, "application/pgp-signature")) if (strcmp (msig->mediatype, "application/pgp-signature"))
gpgprot = GPGME_PROTOCOL_OpenPGP;
else /* Unsupported signature type. */
{ {
/* Unsupported signature type. */
gpgme_release (gpgctx); gpgme_release (gpgctx);
gpgme_data_release (gpgdata); gpgme_data_release (gpgdata);
goto gpg_skip_verification; goto gpg_skip_verification;
} }
gpgerr = gpgme_set_protocol (gpgctx, gpgprot); gpgerr = gpgme_set_protocol (gpgctx, GPGME_PROTOCOL_OpenPGP);
if (gpgerr != GPG_ERR_NO_ERROR) if (gpgerr != GPG_ERR_NO_ERROR)
{ {
logprintf (LOG_NOTQUIET, logprintf (LOG_NOTQUIET,