From patchwork Wed Feb 27 09:05:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 223560 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4864A2C0084 for ; Wed, 27 Feb 2013 20:05:43 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755586Ab3B0JFh (ORCPT ); Wed, 27 Feb 2013 04:05:37 -0500 Received: from intranet.asianux.com ([58.214.24.6]:5003 "EHLO intranet.asianux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755151Ab3B0JFd (ORCPT ); Wed, 27 Feb 2013 04:05:33 -0500 Received: by intranet.asianux.com (Postfix, from userid 103) id D05A3184036A; Wed, 27 Feb 2013 17:05:32 +0800 (CST) X-Spam-Score: -100.8 X-Spam-Checker-Version: SpamAssassin 3.1.9 (2007-02-13) on intranet.asianux.com X-Spam-Level: X-Spam-Status: No, score=-100.8 required=5.0 tests=AWL,BAYES_00, RATWARE_GECKO_BUILD,USER_IN_WHITELIST autolearn=no version=3.1.9 Received: from [10.1.0.143] (unknown [219.143.36.82]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by intranet.asianux.com (Postfix) with ESMTP id 04DE51840325; Wed, 27 Feb 2013 17:05:31 +0800 (CST) Message-ID: <512DCC4A.6060106@asianux.com> Date: Wed, 27 Feb 2013 17:05:14 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 MIME-Version: 1.0 To: Jiri Kosina , isdn@linux-pingi.de, Jiri Slaby , Greg KH CC: alan@linux.intel.com, netdev Subject: [PATCH] drivers/isdn: checkng length to be sure not memory overflow Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org the length of cmd.parm.cmsg.para is 50 (MAX_CAPI_PARA_LEN). the strlen(msg) may be more than 50 (Modem-Commandbuffer, less than 255). isdn_tty_send_msg is called by isdn_tty_parse_at the relative parameter is m->mdmcmd (atemu *m) the relative command may be "+M..." so need check the length to be sure not memory overflow. Signed-off-by: Chen Gang --- drivers/isdn/i4l/isdn_tty.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index d8a7d83..c3f0f99 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c @@ -902,7 +902,7 @@ isdn_tty_send_msg(modem_info *info, atemu *m, char *msg) int j; int l; - l = strlen(msg); + l = min(strlen(msg), sizeof(cmd.parm.cmsg.para) - 2); if (!l) { isdn_tty_modem_result(RESULT_ERROR, info); return;