From patchwork Fri Jan 2 22:39:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 42708 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f198.google.com (mail-we0-f198.google.com [74.125.82.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A6F0D20545 for ; Fri, 2 Jan 2015 22:39:50 +0000 (UTC) Received: by mail-we0-f198.google.com with SMTP id q59sf2470780wes.9 for ; Fri, 02 Jan 2015 14:39:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=jZ5n3cjzzipXWOvkCHsgeuHvQZYAcL5R5qOFrwEKb60=; b=A73xeTl7T35mvTHI5leKA0v/m+U1JL8zFUJPoIhf7I2EQ+JgES4IuXT5H4szT/Kwb6 KGDOuCaBiJUy5jTWCVfYRqoUpXVqxiaHej0JtLu54aplKh6YPMjSUmNlgtxF7M/1uw0Z cd9u+qyVxqLVCbVUx/6ncJbUmeHKOKJP1SF1JnajQRJJR9LhcH6W2BkusWrKXV2yqAnm HKPxe5AvU57pVsYTk+IjL0srI7H0BNiz35CPNaijGPXg92ZxzDYyOT7hFsSG9MksBv1P 2beC7YGDvACGsPlBUB2RyUfd2S3NKRK8jEY94FsZ3gjXNYwSiAtfYXN+yNNdSI77YHb9 sT+g== X-Gm-Message-State: ALoCoQnOnG8Aqj9iGjuWhYTDLYS0olBUQYsK89n+4ZaPXsaeygetE1FlL0mukqIb5zdhCX0El1Va X-Received: by 10.194.178.234 with SMTP id db10mr4118894wjc.2.1420238389847; Fri, 02 Jan 2015 14:39:49 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.131 with SMTP id am3ls229540lac.47.gmail; Fri, 02 Jan 2015 14:39:49 -0800 (PST) X-Received: by 10.112.17.102 with SMTP id n6mr76857194lbd.39.1420238389553; Fri, 02 Jan 2015 14:39:49 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id w3si50154370laj.11.2015.01.02.14.39.47 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Jan 2015 14:39:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id hs14so15696217lab.22 for ; Fri, 02 Jan 2015 14:39:46 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr36739135lbc.23.1420238386400; Fri, 02 Jan 2015 14:39:46 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp304409lbb; Fri, 2 Jan 2015 14:39:45 -0800 (PST) X-Received: by 10.229.181.5 with SMTP id bw5mr22801094qcb.15.1420238385189; Fri, 02 Jan 2015 14:39:45 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id w48si33912790qgw.36.2015.01.02.14.39.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 02 Jan 2015 14:39:45 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y7Asd-0007KA-3j; Fri, 02 Jan 2015 22:39:39 +0000 Received: from mail-qa0-f50.google.com ([209.85.216.50]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y7AsX-0007K5-Dp for lng-odp@lists.linaro.org; Fri, 02 Jan 2015 22:39:33 +0000 Received: by mail-qa0-f50.google.com with SMTP id dc16so13277640qab.9 for ; Fri, 02 Jan 2015 14:39:28 -0800 (PST) X-Received: by 10.229.126.129 with SMTP id c1mr127693379qcs.12.1420238368266; Fri, 02 Jan 2015 14:39:28 -0800 (PST) Received: from localhost.localdomain ([98.221.136.245]) by mx.google.com with ESMTPSA id g60sm34462855qgg.39.2015.01.02.14.39.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 02 Jan 2015 14:39:27 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Fri, 2 Jan 2015 17:39:18 -0500 Message-Id: <1420238358-27553-1-git-send-email-mike.holmes@linaro.org> X-Mailer: git-send-email 2.1.0 X-Topics: patch Subject: [lng-odp] [PATCH] linux-generic: odp_coremask: Catch negative string lengths X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mike.holmes@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Strings of negitive size overwrite the destination string in odp_coremask_to_str, acting as infinite size. Signed-off-by: Mike Holmes --- platform/linux-generic/odp_coremask.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/linux-generic/odp_coremask.c b/platform/linux-generic/odp_coremask.c index 5b4e961..5161008 100644 --- a/platform/linux-generic/odp_coremask.c +++ b/platform/linux-generic/odp_coremask.c @@ -34,6 +34,11 @@ void odp_coremask_to_str(char *str, int len, const odp_coremask_t *mask) { int ret; + if (len < 0) { + ODP_ERR("string has negitive size"); + return; + } + ret = snprintf(str, len, "0x%"PRIx64"", mask->_u64[0]); if (ret >= 0 && ret < len) {