]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Check fr_sbuff_in_bstrncpy() in generate_from_header() (CID #1503908) (#5107)
authorJames Jones <jejones3141@gmail.com>
Thu, 27 Jul 2023 16:00:13 +0000 (11:00 -0500)
committerGitHub <noreply@github.com>
Thu, 27 Jul 2023 16:00:13 +0000 (12:00 -0400)
src/modules/rlm_smtp/rlm_smtp.c

index 5fdb26db2e885452ca142b2f930708e156cbcd88..c0496d0db1c4af9dcf7818f39f7cb6afecc87b3a 100644 (file)
@@ -520,8 +520,9 @@ static int generate_from_header(fr_mail_ctx_t *uctx, struct curl_slist **out, rl
        (void) fr_sbuff_in_strcpy(&sbuff, from);
 
        /* Copy the envelope address as the FROM: source */
-       /* coverity[check_return] */
-       fr_sbuff_in_bstrncpy(&sbuff, inst->envelope_address, strlen(inst->envelope_address));
+       if (unlikely(fr_sbuff_in_bstrncpy(&sbuff, inst->envelope_address, strlen(inst->envelope_address)) < 0)) {
+               return -1;
+       }
        *out = curl_slist_append(*out, sbuff.buff);
 
        /* Free the buffer used to generate the FROM header */
@@ -611,7 +612,10 @@ static int header_source(fr_mail_ctx_t *uctx, rlm_smtp_t const *inst)
        }
 
        /* Add the FROM: line */
-       generate_from_header(uctx, &uctx->header, inst);
+       if (unlikely(generate_from_header(uctx, &uctx->header, inst) < 0)) {
+               RDEBUG2("FROM: header could not be added");
+               return -1;
+       }
 
        /* Add the TO: line if there is one provided in the request by SMTP-TO */
        tmpl_arr_to_header(uctx, &uctx->header, inst->to_addrs, to);