From patchwork Fri May 10 23:53:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Wee X-Patchwork-Id: 13662102 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2076.outbound.protection.outlook.com [40.107.93.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E235175558 for ; Fri, 10 May 2024 23:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.76 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715385216; cv=fail; b=qC96QQ7b4AeuCLmS/2wOHfJUHGESBuTxUtIDtpRBA2A4K5FiF2+M/uIK68Gy3IT+26rk1waxiTRS87kEMkOt1kKHApMtNRn8/1wBvCZu1bv3RBspf7fPr/3j8tXwF0LRlS2sakTJAJPF5vat0ewpEt46nwi2Tn1nhcOs+wuVltU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715385216; c=relaxed/simple; bh=lQMr403+sxHN9PzhjjmZnBjiahYBbPP52t860BxaZDw=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: Content-Type:MIME-Version; b=I79bLYhMPHzTw82PTKPRgNj2ERxc2dTdwduDSFuHldjCxTjuG/ym27s+rhStSQW69FVF3vmEPtE5sIi4l75ug5FqQSLHyPjv7dnPLfeSd3uEM+W9ddAFVgar/qQjptdtK4n49o+8/LezY4pHEQZJnBe/rx8SF08veAawkKZVVGQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=tesla.com; spf=pass smtp.mailfrom=tesla.com; dkim=pass (1024-bit key) header.d=tesla.com header.i=@tesla.com header.b=IjV3+n4M; arc=fail smtp.client-ip=40.107.93.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=tesla.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tesla.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=tesla.com header.i=@tesla.com header.b="IjV3+n4M" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JZcFAnKmGzhkoXv1WU0JvfFQ7B2X3kXaFKFfHRXAh0N8fstq8kM22RhQMD2ka8UVytYcm+yLaFePMCxblSW+U1x9JHIjL1zqtCltHMHDfSL5bCJVADvBTcmG1vgQOQyO1aR9ije9U2S23luaYrVU8lJ0cYJiQV1Vikx+HP87zOLaD+gL2h/xfzfQ4mq8TMZo00cLQvjieXPJ+n3ZzzOm7fYL9p1QEjclRUk22l646wByoLvUvwBWFZvLSQYyO8Rn3shojMkIl8aplcRTeyb0tYozIuE+xYNdkOVe2cZk0Tl1ziy8TyMBQx2ta9WxO5A9MEU1nrfOX8A6si+d1INcRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o1mcHORhrABR3Mv5Lt/BaBDIZDUT7nQNVHZh33Z+0E0=; b=Lid6lXisCoPKat1H91Sm6NK2VzIQMVwRVbXTt+Cf5c0fJoq1DczA1x7D9Djw06QW7xi1Y0M8TIaGAdkU98zoDgfkqA2pnmRcNiKvS0/Up1o9ciCoCwuE7AJIlMd+jpnYWMIGoRvpOQxmlpoC613s4Mcxvkf8LAAfZH6zSVnDbn3PxQ0JJFJmXIBHweM+PgbCYGR3H2CGayyKy4jgacU3nrpAKZIVtzjGSqlL1XKQOaozd69b06cTtu6oaEh4g+sBgtAPd7NDl+d5n3H0QOp/WdcmMOnIT2zVdLyuD9WVLY5LqwFW6e4OKjtzRNxkB+aQgYWsb3cHzZsT3KHwn+Us7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=tesla.com; dmarc=pass action=none header.from=tesla.com; dkim=pass header.d=tesla.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tesla.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o1mcHORhrABR3Mv5Lt/BaBDIZDUT7nQNVHZh33Z+0E0=; b=IjV3+n4MLAaSSgZCu+e0p2puauIoW0iU48RLPm0IrkB+vk8m1yTAnNpRG3G5/vzzI5ezs2CIwXnFPtt8K+5/AkVu3sNKvmDQMleFDnZ6td1WAFKxUdsrJDJqoQzF7Ir1FVtzKfS0mfwpqvNpsH92V7dpTCVKUAWW2aBjJmFXH+c= Received: from DM8PR16MB4504.namprd16.prod.outlook.com (2603:10b6:8:7::20) by DS0PR16MB5368.namprd16.prod.outlook.com (2603:10b6:8:167::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.47; Fri, 10 May 2024 23:53:30 +0000 Received: from DM8PR16MB4504.namprd16.prod.outlook.com ([fe80::ad2f:63a4:40b3:ea63]) by DM8PR16MB4504.namprd16.prod.outlook.com ([fe80::ad2f:63a4:40b3:ea63%5]) with mapi id 15.20.7544.048; Fri, 10 May 2024 23:53:30 +0000 From: Colin Wee To: Marcel Holtmann CC: "connman@lists.linux.dev" Subject: [PATCH] Prevent a short allocation by checking upper_length Thread-Topic: [PATCH] Prevent a short allocation by checking upper_length Thread-Index: AQHaozVC4DTBzVpAzUaX26jraTWGdrGRJAkA Date: Fri, 10 May 2024 23:53:30 +0000 Message-ID: <20240510235325.3625167-2-cwee@tesla.com> References: <555F580E-1735-4CB1-89F0-7866013F6D47@holtmann.org> <20240510235325.3625167-1-cwee@tesla.com> In-Reply-To: <20240510235325.3625167-1-cwee@tesla.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.45.0 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=tesla.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DM8PR16MB4504:EE_|DS0PR16MB5368:EE_ x-ms-office365-filtering-correlation-id: 4eeb4438-3893-4a4d-660d-08dc714c650d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230031|1800799015|366007|376005|38070700009; x-microsoft-antispam-message-info: =?iso-8859-1?q?4u7rMWOfYXNWvkAU7rMt0jgYRi?= =?iso-8859-1?q?0emepTfjzv1+vQ4tHwLbN7/efuNhGq3JPYKbdQZSg6ic01chepei1v0a6c3R?= =?iso-8859-1?q?pt598A4FjRZvryUVNjiFzcJY474pQPk3CpNycjoGFbNMLijmX47jb5nZatsN?= =?iso-8859-1?q?AFdAnX1Lhxz5QEzX4FbGRl5y8YjFukh8jP4OYQbDnaMyJCnaAMJAlKD+F+1J?= =?iso-8859-1?q?UzSC2BAes4nre524ceMPpgSztEJ1qrjrx2Yhry7oopEAWbTXexHgwfBK7g4/?= =?iso-8859-1?q?u2eDqUqP2Jjxmxzm88gbshJqgKDNpOk+CXOJkjfBcR+xMP89TqH7VrlwG+E9?= =?iso-8859-1?q?O6Qes6Z1XvGoYeWPRHYXNmuh+zIIHdld7KSzE2nmZEJ+G4Rj2v2b9+EJGCrE?= =?iso-8859-1?q?PNw8PdGBLgSdPZhH9sKmwY4g9E7dLI56ULSk96xD0MwgX3OV15HylWj+n35j?= =?iso-8859-1?q?lvzCFLihYnxX7v6SuJthXJIC7qfhxKq1WCwphNlZ0sbR0gkQaR3UkgpzUemg?= =?iso-8859-1?q?STPSGYFKFPh8ZFozuYnHq3KlokVfDlfpjD3T7REvO5NLjokVX098uT972H13?= =?iso-8859-1?q?n06t0nkbLgedHuLqLlGC/vcOVfz00trIs5t04+byO9OARGuUU8+V4Lv3GOPm?= =?iso-8859-1?q?f6/TAvwYKfIdiUtapfwBReQLSsKYkiQCzbOXWvreeUeIDy4EPXFi88vSh8H7?= =?iso-8859-1?q?HBsZ9aeyhcbNt0CItx8garXa3iIVgHwTECZvFVarVXvNL3rnuEe1kyTOTIXG?= =?iso-8859-1?q?AV/Jwb+tTesgXvAw7lnGV/iNhdRWE4H/4ZLHnCWXsBAebBUMRfhu0fBvYHi8?= =?iso-8859-1?q?+hiil8HmWy9GNUxgz2XYHmZwbezI0peFQrBINwcNbFyx8g2J6+0eUu4KmjnX?= =?iso-8859-1?q?nf4W6SGu+eXuy+ZsRDZqdAIdd+PEM/m1rFEDSKJsHu8oMbHCR5syGOZdnmdh?= =?iso-8859-1?q?A9NQi3//26buiTUt93FbOv9ujSu8UhpQqh24QZoRtnE+JReIAxoe+UwKWatr?= =?iso-8859-1?q?V5imWfPDkkvO3ZhNMdySpfKPRn/GD3Nl5kqtGx0NA5A6drgJrQXzqGU+JXVm?= =?iso-8859-1?q?XBCD/axwsDN+dS27a521jUBEbuPsYOWR4ChymlgFIQVb54NHr2l9ao9Yq7ho?= =?iso-8859-1?q?YfiFE+WlVaV9LQXKhf2xHcAbmVDPDqbKU37/+qfIuXGSnOecCT9ofgcadGms?= =?iso-8859-1?q?llbgXOrhbLg0+5bxIcJ70wbaZIyMagO88CHG6erWeQKW/IGWvh+oDeaghV/g?= =?iso-8859-1?q?xSoIg6JKunXa2qUn9bootVQGZPV3BKwGeVwGzRlauxMa1bWJa98OJDKwy6eV?= =?iso-8859-1?q?RkAp0xcGDr0psgUCKx/Y9RUFWHopdYAXuTQFtBVbqCNpYIGBQGaK8L49+I5H?= =?iso-8859-1?q?mJkRhpibW9ErNo6xPmIQ=3D=3D?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR16MB4504.namprd16.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(1800799015)(366007)(376005)(38070700009);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?5Kzat7PRAO33qRVj+Letp79?= =?iso-8859-1?q?xjf6VhCMoWc50QUR3aOyYberoBYcgO3FciPwfIdXEsGrkKNw8AhRqpmk7FoX?= =?iso-8859-1?q?6ORJmZfz9j47FaR1FWojXv32WzxCzlxB/k0gCfoBXynY9djE5VXogzf0JsBc?= =?iso-8859-1?q?HC3TAq6ggK8X+lwY5ha+Bi752UCEdzGgt0BjfupO1BIPho8ZOUjraTxP9D40?= =?iso-8859-1?q?Aj+TAkem9qZrf2yJjYjC4aYX5SlB+0RZ46tV37YJkNtIKb1Zc4obIsiE11TB?= =?iso-8859-1?q?dFa9nYdKhJfUaGPOa0iJz3t6s/2p8NJQ3k7uMHcbMvUAZY0HrfjIH+42tsSH?= =?iso-8859-1?q?ZcKK+1z0W5WpIJXSS9knp6yG7/Zs6U8lKNCf1W7TEHrHWkH8MMIsaoTRjrQ1?= =?iso-8859-1?q?fh7qdMgqJNtEZe0VXOb6GEAZ8TUOVyxnYIeAV2arwBn3bBvYghii1Ab/Z1aU?= =?iso-8859-1?q?HZ5prxVViwXUO1VAS9vD+gHx14yQeyzBLZBOSaRXNq8q9K3+qEiDzNhcAbXu?= =?iso-8859-1?q?tRK01ZXw5GksK9/rZD8TlIxIR62eV+7eZF4KAGGFG2WA+wDukX1gIC41J2w4?= =?iso-8859-1?q?N1sWquobzuYmmQkksUEdwjhjxvUsakp8pngNP+D0CtSa/jBQ17Hjj7S7Tczq?= =?iso-8859-1?q?Oa0XoPJjhFPhs4uouUsH3HjrLjVIyXC7tiXdEvTiuud4Ss7r8U8W25WnlGvL?= =?iso-8859-1?q?AIYLzuBbA9rnds3mUdcmlU3nADLR5RAjuA/1H4NpsKVoZFprgoPop5jVDAtx?= =?iso-8859-1?q?Hk5kAAH5qjj29W5pZTj2vX60lePbYc+ON2d0WvRaa/0Iu9BvOf21jEay88ig?= =?iso-8859-1?q?1JMbxwrpGBdttc25egg8tbyivYVTS/VWroTcrxL0JzexX5u4mpAY5ta6hK4d?= =?iso-8859-1?q?nV8zvff8Z2Vt5TbzeIykQvdIKyotuIoUV0Fba9+IFTBIEUgQbdqqd/ltYK5H?= =?iso-8859-1?q?OTtbEfttcw3TCRzHTPPIJNmoknqHqTo2IYCdj6oijfOxV4w40DDxHg6jko2h?= =?iso-8859-1?q?ji25XiI23QflTlBJwTcF87RD6CTXEhvA2O1tP2pq1MQOjwydNaszM6waPsB2?= =?iso-8859-1?q?eUDtYkdgzmB9QIxzRaIDtNaXY5ODZMbCa1udaekBUOCjGPoEAoCVbbNU1O12?= =?iso-8859-1?q?Jz0dspIaxSXzlHyGDoUWJXv4nZ/YjVocZaX1TIkArxWf/H02Mw7WvArw5KOg?= =?iso-8859-1?q?Tlfa7+vKxg2/HawWtnKaiCfgtWCJPih06UgXyUOs0EGiBL+wHkD7fiaQW+av?= =?iso-8859-1?q?Tak04kgZLMdNgHdPjxge/2A9B4H5S2hqOG6COQpU0ib20rO3UDSiaJDRlc14?= =?iso-8859-1?q?iy9w3cl3Uxk5i7wyBnzLzrBdvd6WpK8SXR9YfUC9Yb0KOLsI2foo+eA7ZvQ9?= =?iso-8859-1?q?UjUSxqwPKt6l+abkCqj403hXjKDNxoz6uwKs4IWM3wzdId0M7BTlyFViX84z?= =?iso-8859-1?q?6zqmjBN1YILk90UDWyW32BCULOL3Lamn1srhvVySPp2O7lNS6ebP0cKqQvUf?= =?iso-8859-1?q?aWEb4YLqClOg7u8Z+S05A8pcUt5sZ8nMrCMc4mAWE0iFu+98IZ2NanaSISjI?= =?iso-8859-1?q?V79MZuUyNhVlgyqNHKoM6F4knni1X3gOHuHXAObdE6lYrTX2JJ+VaHSxwlaI?= =?iso-8859-1?q?kRT1yGo4UBy8fqdro?= Precedence: bulk X-Mailing-List: connman@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: tesla.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR16MB4504.namprd16.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4eeb4438-3893-4a4d-660d-08dc714c650d X-MS-Exchange-CrossTenant-originalarrivaltime: 10 May 2024 23:53:30.6123 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9026c5f4-86d0-4b9f-bd39-b7d4d0fb4674 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: j473d5kqC5r/ED0BAE9+ZctbZlF3V4EbrzVof+dZW8namX3+iuGI9gKnF6uD4YQ2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR16MB5368 From: Craig Young --- gdhcp/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdhcp/client.c b/gdhcp/client.c index 2afa19e6..c9234a18 100644 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -1863,6 +1863,8 @@ static char *malloc_option_value_string(uint8_t *option, GDHCPOptionType type) return NULL; upper_length = len_of_option_as_string[type] * ((unsigned)len / (unsigned)optlen); + if (upper_length == 0) + return NULL; dest = ret = g_malloc(upper_length + 1); if (!ret) return NULL;