From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BE299158043 for ; Mon, 15 Apr 2024 11:58:57 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 08416E29C0; Mon, 15 Apr 2024 11:58:57 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id DA986E29C0 for ; Mon, 15 Apr 2024 11:58:56 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EB1B9343356 for ; Mon, 15 Apr 2024 11:58:55 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 244501620 for ; Mon, 15 Apr 2024 11:58:54 +0000 (UTC) From: "Adrian Ratiu" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Adrian Ratiu" Message-ID: <1713182323.7e6af504b7ecca1853034f60eb6dd6dc20f2ce46.adrian.ratiu@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: dev-libs/libtypec/, dev-libs/libtypec/files/ X-VCS-Repository: repo/proj/guru X-VCS-Files: dev-libs/libtypec/files/libtypec-0.5.0-libtypec-close-fp-before-returning.patch dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-break-in-switch-statement.patch dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-fun.patch dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-function.patch dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-close-fp-before-returning.patch dev-libs/libtypec/files/libtypec-0.5.0-typecstatus-fix-potential-overflow.patch dev-libs/libtypec/libtypec-0.5.0-r1.ebuild dev-libs/libtypec/libtypec-0.5.0.ebuild X-VCS-Directories: dev-libs/libtypec/ dev-libs/libtypec/files/ X-VCS-Committer: adrian.ratiu X-VCS-Committer-Name: Adrian Ratiu X-VCS-Revision: 7e6af504b7ecca1853034f60eb6dd6dc20f2ce46 X-VCS-Branch: dev Date: Mon, 15 Apr 2024 11:58:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 2eda1287-fd7b-4cbf-a98d-fef81b3bdac0 X-Archives-Hash: 8c0bafb75aec265f39393be6b7154cbf commit: 7e6af504b7ecca1853034f60eb6dd6dc20f2ce46 Author: Adrian Ratiu collabora com> AuthorDate: Mon Apr 15 11:04:25 2024 +0000 Commit: Adrian Ratiu collabora com> CommitDate: Mon Apr 15 11:58:43 2024 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=7e6af504 dev-util/libtypec: backport a few more patches These should all be dropped when upstream does a new release. Signed-off-by: Adrian Ratiu collabora.com> ...-0.5.0-libtypec-close-fp-before-returning.patch | 33 +++++++++ ...ils-add-missing-break-in-switch-statement.patch | 30 ++++++++ ...ec-utils-add-missing-return-at-end-of-fun.patch | 31 ++++++++ ...ils-add-missing-return-at-end-of-function.patch | 30 ++++++++ ...-libtypec-utils-close-fp-before-returning.patch | 44 ++++++++++++ ...-0.5.0-typecstatus-fix-potential-overflow.patch | 82 ++++++++++++++++++++++ dev-libs/libtypec/libtypec-0.5.0-r1.ebuild | 1 + dev-libs/libtypec/libtypec-0.5.0.ebuild | 6 ++ 8 files changed, 257 insertions(+) diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-close-fp-before-returning.patch b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-close-fp-before-returning.patch new file mode 100644 index 0000000000..e8fe5d44bf --- /dev/null +++ b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-close-fp-before-returning.patch @@ -0,0 +1,33 @@ +From 67d40a5f0132e2b02167ad274c6d6c76e4393964 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 4 Jan 2024 09:42:54 +0000 +Subject: [PATCH] libtypec: close fp before returning + +Fix resource leak on fp on error return path, close fp before +returning. + +Signed-off-by: Colin Ian King +Upstream-Status: Backport [upstream commit 67d40a5] +--- + libtypec_sysfs_ops.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/libtypec_sysfs_ops.c b/libtypec_sysfs_ops.c +index 747b562..a22de5a 100644 +--- a/libtypec_sysfs_ops.c ++++ b/libtypec_sysfs_ops.c +@@ -504,8 +504,10 @@ static int count_billbrd_if(const char *usb_path, const struct stat *sb, int typ + if(num_bb_if < MAX_BB_PATH_STORED) + { + int len = strlen(usb_path); +- if(len > 512 ) /*exceeds buffer size*/ ++ if(len > 512 ) { /*exceeds buffer size*/ ++ fclose(fd); + return 0; ++ } + + strcpy(bb_dev_path[num_bb_if],usb_path); + } +-- +2.43.2 + diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-break-in-switch-statement.patch b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-break-in-switch-statement.patch new file mode 100644 index 0000000000..e48fcac1cb --- /dev/null +++ b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-break-in-switch-statement.patch @@ -0,0 +1,30 @@ +From 7de1000ff658c594a8f0a4b62f4956fc635d6c23 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 4 Jan 2024 09:46:19 +0000 +Subject: [PATCH] libtypec: utils: add missing break in switch statement + +For the product_type_pd3p1_drd case there is a missing break +statement causing an unintentional fall-through to the default +case. Add in the missing break statement. + +Signed-off-by: Colin Ian King +Upstream-Status: Backport [upstream commit 7de1000] +--- + utils/lstypec.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/utils/lstypec.c b/utils/lstypec.c +index a30b2bc..98d23f6 100644 +--- a/utils/lstypec.c ++++ b/utils/lstypec.c +@@ -396,6 +396,7 @@ void print_identity_data(int recipient, union libtypec_discovered_identity id, s + printf(" Product VDO 2: 0x%08x\n", id.disc_id.product_type_vdo2); + printf(" Product VDO 3: 0x%08x\n", id.disc_id.product_type_vdo3); + print_vdo(((uint32_t) id.disc_id.product_type_vdo3), 6, pd3p1_dfp_fields, pd3p1_dfp_field_desc); ++ break; + default: + printf(" Product VDO 1: 0x%08x\n", id.disc_id.product_type_vdo1); + printf(" Product VDO 2: 0x%08x\n", id.disc_id.product_type_vdo2); +-- +2.43.2 + diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-fun.patch b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-fun.patch new file mode 100644 index 0000000000..554c0006ac --- /dev/null +++ b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-fun.patch @@ -0,0 +1,31 @@ +From 6d193776421db948e4201a60cf239fdae62c196d Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 4 Jan 2024 09:52:57 +0000 +Subject: [PATCH] libtypec: utils: add missing return at end of function + +Function typecstatus_power_contract is missing a return 0 at the +end of the function, currently it is returning nothing and so +it may be returning a garbage value. + +Signed-off-by: Colin Ian King +Upstream-Status: Backport [upstream commit 6d19377] +--- + utils/typecstatus.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/utils/typecstatus.c b/utils/typecstatus.c +index 5e16e74..bfb4142 100644 +--- a/utils/typecstatus.c ++++ b/utils/typecstatus.c +@@ -208,7 +208,7 @@ int typecstatus_power_contract() + printf("\tNo Power Contract on port %d\n",i); + } + } +- ++ return 0; + } + + /* Check all typec ports */ +-- +2.43.2 + diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-function.patch b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-function.patch new file mode 100644 index 0000000000..9f33b91490 --- /dev/null +++ b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-add-missing-return-at-end-of-function.patch @@ -0,0 +1,30 @@ +From d15c9d17148632b7864990c29854321b891c95c3 Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 4 Jan 2024 09:44:04 +0000 +Subject: [PATCH] libtypec: utils: add missing return at end of function + +Function typec_status_billboard is missing a return 0 at the +end of the function, currently it is returning nothing and so +it may be returning a garbage value. + +Signed-off-by: Colin Ian King +Upstream-Status: Backport [upstream commit d15c9d1] +--- + utils/typecstatus.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/utils/typecstatus.c b/utils/typecstatus.c +index 43801c0..5e16e74 100644 +--- a/utils/typecstatus.c ++++ b/utils/typecstatus.c +@@ -169,6 +169,7 @@ int typec_status_billboard() + + } + } ++ return 0; + } + + int typecstatus_power_contract() +-- +2.43.2 + diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-close-fp-before-returning.patch b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-close-fp-before-returning.patch new file mode 100644 index 0000000000..3479673749 --- /dev/null +++ b/dev-libs/libtypec/files/libtypec-0.5.0-libtypec-utils-close-fp-before-returning.patch @@ -0,0 +1,44 @@ +From 477b08cea7e27da5fb97ce52d0af3d2c98f4f98f Mon Sep 17 00:00:00 2001 +From: Colin Ian King +Date: Thu, 4 Jan 2024 09:41:04 +0000 +Subject: [PATCH] libtypec: utils: close fp before returning + +Fix resource leak on fp on error return path, close fp before +returning. + +Signed-off-by: Colin Ian King +Upstream-Status: Backport [upstream commit 477b08c] +--- + utils/typecstatus.c | 8 +++++--- + 1 file changed, 5 insertions(+), 3 deletions(-) + +diff --git a/utils/typecstatus.c b/utils/typecstatus.c +index be906a4..43801c0 100644 +--- a/utils/typecstatus.c ++++ b/utils/typecstatus.c +@@ -92,11 +92,13 @@ static unsigned long get_dword_from_path(char *path) + + FILE *fp = fopen(path, "r"); + +- if (fp == NULL) ++ if (fp == NULL) + return -1; + +- if(fgets(buf, 64, fp) == NULL) ++ if(fgets(buf, 64, fp) == NULL) { ++ fclose(fp); + return -1; ++ } + + dword = strtoul(buf, NULL, 10); + +@@ -253,4 +255,4 @@ int main (int argc, char **argv) + } + names_exit(); + +-} +\ No newline at end of file ++} +-- +2.43.2 + diff --git a/dev-libs/libtypec/files/libtypec-0.5.0-typecstatus-fix-potential-overflow.patch b/dev-libs/libtypec/files/libtypec-0.5.0-typecstatus-fix-potential-overflow.patch new file mode 100644 index 0000000000..c7479f0091 --- /dev/null +++ b/dev-libs/libtypec/files/libtypec-0.5.0-typecstatus-fix-potential-overflow.patch @@ -0,0 +1,82 @@ +From 026acf3f2688631af2951630d3b9588badc65ca6 Mon Sep 17 00:00:00 2001 +From: Rajaram Regupathy +Date: Sun, 14 Apr 2024 14:55:15 +0530 +Subject: [PATCH] typecstatus : fix potential overflow + +check index returned and use to avoid potential buffer overflow +Upstream-Status: Backport [upstream commit 026acf3] +--- + utils/typecstatus.c | 44 +++++++++++++++++++++++--------------------- + 1 file changed, 23 insertions(+), 21 deletions(-) + +diff --git a/utils/typecstatus.c b/utils/typecstatus.c +index bfb4142..7ca7669 100644 +--- a/utils/typecstatus.c ++++ b/utils/typecstatus.c +@@ -133,40 +133,42 @@ int typec_status_billboard() + + bb_loc = find_bb_bos_index(bb_data,ret); + +- struct bb_bos_descritor *bb_bos_desc = (struct bb_bos_descritor *)&bb_data[bb_loc]; ++ if(bb_loc > 0 ) ++ { ++ struct bb_bos_descritor *bb_bos_desc = (struct bb_bos_descritor *)&bb_data[bb_loc]; + +- printf("\tBillboard Device Version : %x.%x\n",bb_bos_desc->cap_desc_bcd_ver[1],bb_bos_desc->cap_desc_bcd_ver[0]); ++ printf("\tBillboard Device Version : %x.%x\n",bb_bos_desc->cap_desc_bcd_ver[1],bb_bos_desc->cap_desc_bcd_ver[0]); + +- printf("\tNumber of Alternate Mode : %d\n",bb_bos_desc->cap_desc_num_aum); ++ printf("\tNumber of Alternate Mode : %d\n",bb_bos_desc->cap_desc_num_aum); + +- for(int x=0;xcap_desc_num_aum;x++) +- { +- int idx = 0, k=0, j=0; +- #define bmCONF_STR_ARR_MAX 4 ++ for(int x=0;xcap_desc_num_aum;x++) ++ { ++ int idx = 0, k=0, j=0; ++ #define bmCONF_STR_ARR_MAX 4 + +- char *bmconf_str_array[]= {"Unspecified Error","AUM not attempted","AUM attempt unsuccessful","AUM configuration successful","Undefined Configuration"}; ++ char *bmconf_str_array[]= {"Unspecified Error","AUM not attempted","AUM attempt unsuccessful","AUM configuration successful","Undefined Configuration"}; + +- if( (x !=0) && ((x % 4) == 0)) +- { +- j++; +- k=0; +- } ++ if( (x !=0) && ((x % 4) == 0)) ++ { ++ j++; ++ k=0; ++ } + +- idx = bb_bos_desc->cap_desc_bmconfig[j]; ++ idx = bb_bos_desc->cap_desc_bmconfig[j]; + +- idx = (idx >> k) & 0x3; ++ idx = (idx >> k) & 0x3; + +- k++; ++ k++; + +- idx = idx < bmCONF_STR_ARR_MAX ? idx : bmCONF_STR_ARR_MAX; ++ idx = idx < bmCONF_STR_ARR_MAX ? idx : bmCONF_STR_ARR_MAX; + +- char *aum = &bb_bos_desc->cap_desc_aum_array_start; ++ char *aum = &bb_bos_desc->cap_desc_aum_array_start; + +- aum = aum + (x*4); ++ aum = aum + (x*4); + +- printf("\tAlternate Mode 0x%02X%02X in state : %s\n",aum[1]&0xFF,aum[0]&0xFF,bmconf_str_array[idx]); ++ printf("\tAlternate Mode 0x%02X%02X in state : %s\n",aum[1]&0xFF,aum[0]&0xFF,bmconf_str_array[idx]); ++ } + } +- + } + } + return 0; +-- +2.43.2 + diff --git a/dev-libs/libtypec/libtypec-0.5.0-r1.ebuild b/dev-libs/libtypec/libtypec-0.5.0-r1.ebuild new file mode 120000 index 0000000000..6fadeb75a3 --- /dev/null +++ b/dev-libs/libtypec/libtypec-0.5.0-r1.ebuild @@ -0,0 +1 @@ +libtypec-0.5.0.ebuild \ No newline at end of file diff --git a/dev-libs/libtypec/libtypec-0.5.0.ebuild b/dev-libs/libtypec/libtypec-0.5.0.ebuild index 02697c52d9..0e9c08e3aa 100644 --- a/dev-libs/libtypec/libtypec-0.5.0.ebuild +++ b/dev-libs/libtypec/libtypec-0.5.0.ebuild @@ -19,6 +19,12 @@ PATCHES=( "${FILESDIR}/${PN}-0.5.0-CMakeLists.txt-fix-pkgconfig-install-path.patch" "${FILESDIR}/${PN}-0.5.0-sysfs_ops-define-feature-test-macro-for-nft.patch" "${FILESDIR}/${PN}-0.5.0-sysfs_ops-fix-nftw-fun-pointer-def.patch" + "${FILESDIR}/${PN}-0.5.0-libtypec-utils-close-fp-before-returning.patch" + "${FILESDIR}/${PN}-0.5.0-libtypec-close-fp-before-returning.patch" + "${FILESDIR}/${PN}-0.5.0-libtypec-utils-add-missing-return-at-end-of-fun.patch" + "${FILESDIR}/${PN}-0.5.0-libtypec-utils-add-missing-return-at-end-of-function.patch" + "${FILESDIR}/${PN}-0.5.0-libtypec-utils-add-missing-break-in-switch-statement.patch" + "${FILESDIR}/${PN}-0.5.0-typecstatus-fix-potential-overflow.patch" ) src_configure() {