Commit 942a9dec authored by Kevin J. McCarthy's avatar Kevin J. McCarthy

Fix chomp in smime_handle_cert_email.

During a review of the previous patch, Oswald Buddenhagen noticed two
of the fixed oob reads had another problem: they were "chomping" (the
newline) without verifying there actually was a newline at the end of
the string.
parent 3f917d7d
......@@ -956,8 +956,8 @@ static int smime_handle_cert_email (char *certificate, char *mailbox,
while ((fgets (email, sizeof (email), fpout)))
{
len = mutt_strlen (email);
if (len)
*(email + len - 1) = '\0';
if (len && (email[len - 1] == '\n'))
email[len - 1] = '\0';
if(mutt_strncasecmp (email, mailbox, mutt_strlen (mailbox)) == 0)
ret=1;
......@@ -986,8 +986,8 @@ static int smime_handle_cert_email (char *certificate, char *mailbox,
while ((fgets (email, sizeof (email), fpout)))
{
len = mutt_strlen (email);
if (len)
*(email + len - 1) = '\0';
if (len && (email[len - 1] == '\n'))
email[len - 1] = '\0';
(*buffer)[count] = safe_calloc(1, mutt_strlen (email) + 1);
strncpy((*buffer)[count], email, mutt_strlen (email));
count++;
......
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