[Rpm-maint] [rpm-software-management/rpm] Prevent buffer overruns in findPreambleTag() for language string (PR #4188)

Dave Cantrell notifications at github.com
Wed Apr 22 12:56:25 UTC 2026


@dcantrell commented on this pull request.



> @@ -1177,14 +1179,17 @@ static int findPreambleTag(rpmSpec spec, PreambleRec * pr, const char ** macro,
     case 2:
 	if (*s == ':') {
 	    /* Type 1 is multilang, 2 is qualifiers with no defaults */
-	    strcpy(lang, (p->type == 1) ? RPMBUILD_DEFAULT_LANG : "");
+	    strlcpy(lang, (p->type == 1) ? RPMBUILD_DEFAULT_LANG : "", langsize);

Ah yes, I forgot that POSIX is not in the business of providing safe string functions.  I've been in the habit now of using strlcat and strlcpy, but forgot they've only been around for 28 years so far in the libbsd side car.  :)

You want a fun read, take a look at string_copying(7).  My favorite are the defined functions that are then noted as not being implemented by any library.

Updating this PR momentarily.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/4188?email_source=notifications&email_token=ADLPZU3WS23VZGPAWENJP334XC6PTA5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTIMJVGQ4DANZUGQ3KM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOS6XA4S7OJSXM2LFO5PW433UNFTGSY3BORUW63TTL5RWY2LDNM#discussion_r3124080727
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/4188/review/4154807446 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20260422/c05d9aa6/attachment.htm>


More information about the Rpm-maint mailing list