From patchwork Tue Nov 11 07:59:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Yufen X-Patchwork-Id: 409197 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id B4F371400F4 for ; Tue, 11 Nov 2014 19:02:35 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A291291C29; Tue, 11 Nov 2014 08:02:34 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pPGSC1dq5-DA; Tue, 11 Nov 2014 08:02:31 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 5B2F091C82; Tue, 11 Nov 2014 08:02:31 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 823DB1C20A0 for ; Tue, 11 Nov 2014 08:02:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7B2712FB41 for ; Tue, 11 Nov 2014 08:02:30 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SIRxTkFOjERV for ; Tue, 11 Nov 2014 08:02:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [119.145.14.65]) by silver.osuosl.org (Postfix) with ESMTPS id D58E12FB21 for ; Tue, 11 Nov 2014 08:02:27 +0000 (UTC) Received: from 172.24.2.119 (EHLO szxeml412-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CCE26230; Tue, 11 Nov 2014 16:02:22 +0800 (CST) Received: from [127.0.0.1] (10.177.25.231) by szxeml412-hub.china.huawei.com (10.82.67.91) with Microsoft SMTP Server id 14.3.158.1; Tue, 11 Nov 2014 15:59:17 +0800 Message-ID: <5461C1CF.4090409@huawei.com> Date: Tue, 11 Nov 2014 15:59:11 +0800 From: wangyufen User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Subject: [PATCH] add argument check in mknod X-Originating-IP: [10.177.25.231] X-CFilter-Loop: Reflected Cc: Wang Nan X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" mknod() in glibc/eglibc will check the argument, like this, ... if (k_dev != dev) { __set_errno (EINVAL); return -1; } ... So add argument check in uclibc's mknod() too. Signed-off-by: Wang Yufen --- libc/sysdeps/linux/common/mknod.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/libc/sysdeps/linux/common/mknod.c b/libc/sysdeps/linux/common/mknod.c index 416cab6..29e21ac 100644 --- a/libc/sysdeps/linux/common/mknod.c +++ b/libc/sysdeps/linux/common/mknod.c @@ -24,6 +24,10 @@ int mknod(const char *path, mode_t mode, dev_t dev) /* We must convert the value to dev_t type used by the kernel. */ k_dev = (dev) & ((1ULL << 32) - 1); + if (k_dev != dev) { + __set_errno (EINVAL); + return -1; + } return INLINE_SYSCALL(mknod, 3, path, mode, (unsigned int)k_dev); } #endif