From patchwork Thu Sep 17 09:21:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: heinzm@sourceware.org X-Patchwork-Id: 48262 Received: from hormel.redhat.com (hormel1.redhat.com [209.132.177.33]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8H9LPA4008929 for ; Thu, 17 Sep 2009 09:21:25 GMT Received: from listman.util.phx.redhat.com (listman.util.phx.redhat.com [10.8.4.110]) by hormel.redhat.com (Postfix) with ESMTP id 05A2C619796; Thu, 17 Sep 2009 05:21:25 -0400 (EDT) Received: from int-mx03.intmail.prod.int.phx2.redhat.com (nat-pool.util.phx.redhat.com [10.8.5.200]) by listman.util.phx.redhat.com (8.13.1/8.13.1) with ESMTP id n8H9LMRP023909 for ; Thu, 17 Sep 2009 05:21:22 -0400 Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.10]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8H9LLmm002362 for ; Thu, 17 Sep 2009 05:21:21 -0400 Received: from sourceware.org (sourceware.org [209.132.176.174]) by mx1.redhat.com (8.13.8/8.13.8) with SMTP id n8H9L8SK028084 for ; Thu, 17 Sep 2009 05:21:08 -0400 Received: (qmail 25226 invoked by uid 9450); 17 Sep 2009 09:21:08 -0000 Date: 17 Sep 2009 09:21:08 -0000 Message-ID: <20090917092108.25224.qmail@sourceware.org> From: heinzm@sourceware.org To: dm-cvs@sourceware.org, dm-devel@redhat.com X-RedHat-Spam-Score: -4 (RCVD_IN_DNSWL_MED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-Scanned-By: MIMEDefang 2.67 on 10.5.110.10 X-loop: dm-devel@redhat.com Cc: Subject: [dm-devel] dmraid/lib/format/ataraid jm.c X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.5 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com CVSROOT: /cvs/dm Module name: dmraid Changes by: heinzm@sourceware.org 2009-09-17 09:21:07 Modified files: lib/format/ataraid: jm.c Log message: JMicron name termination fix Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/dmraid/lib/format/ataraid/jm.c.diff?cvsroot=dm&r1=1.4&r2=1.5 --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel --- dmraid/lib/format/ataraid/jm.c 2008/06/20 21:52:17 1.4 +++ dmraid/lib/format/ataraid/jm.c 2009/09/17 09:21:07 1.5 @@ -25,18 +25,18 @@ static char * name(struct lib_context *lc, struct raid_dev *rd, unsigned int subset) { - int i; - size_t len; + size_t i, len; struct jm *jm = META(rd, jm); - char buf[JM_NAME_LEN + 1], *ret, *name = (char *) jm->name; + char *ret, *name = (char *) jm->name; + char buf[JM_NAME_LEN + 1] = { '\0' }; - /* Name always 0 terminated or whitespace at end ? */ + /* Sanitize name, make sure it's null terminated */ strncpy(buf, name, JM_NAME_LEN); - len = strlen(buf); - i = len < JM_NAME_LEN ? len : JM_NAME_LEN; - buf[i] = 0; - while (i-- && isspace(buf[i])) - buf[i] = 0; + while (i && isspace(buf[i])) { + name[i]='\0'; + buf[i]='\0'; + --i; + } len = strlen(buf) + sizeof(HANDLER) + (jm->mode == JM_T_RAID01 ? 3 : 2); if ((ret = dbg_malloc(len))) {