Package: dmraid Severity: wishlist Version: 1.0.0.rc14-1 User: [EMAIL PROTECTED] Usertags: origin-ubuntu ubuntu-patch hardy ubuntu
Attached is a patch to fix a segmentation fault when attempting to generate device names for use with Jmicron controller metadata. This patch is currently in the Ubuntu dmraid package, and therefore the attached patch is in dpatch format. It would be nice if this patch was in the Debian package, thereby reducing the delta between Ubuntu and Debian. Taken from the ataraid mailing list. Luke
#! /bin/sh /usr/share/dpatch/dpatch-run ## 10_jmicron-name-fix.dpatch by Luke Yelavich <[EMAIL PROTECTED]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: Fix segfault when attempting to generate name for jmicron controllers. @DPATCH@ diff -urNad dmraid-1.0.0.rc14-1ubuntu1~/1.0.0.rc14/lib/format/ataraid/jm.c dmraid-1.0.0.rc14-1ubuntu1/1.0.0.rc14/lib/format/ataraid/jm.c --- dmraid-1.0.0.rc14-1ubuntu1~/1.0.0.rc14/lib/format/ataraid/jm.c 2006-09-23 01:24:03.000000000 +1000 +++ dmraid-1.0.0.rc14-1ubuntu1/1.0.0.rc14/lib/format/ataraid/jm.c 2008-07-08 14:36:57.000000000 +1000 @@ -28,10 +28,16 @@ size_t len; struct jm *jm = META(rd, jm); char buf[2], *ret, *name = (char *) jm->name; + char buf0[JM_NAME_LEN+1] = { '\0' }; + size_t i = JM_NAME_LEN-1; - /* Name always 0 terminated ? */ - if ((len = strlen(name)) > JM_NAME_LEN) - len = JM_NAME_LEN; + /* Sanitize name, make sure it's null terminated */ + strncpy(buf0, jm->name, JM_NAME_LEN); + while (i!=0 && buf0[i]==' ') { + buf0[i]='\0'; + --i; + } + len = strlen(buf0); len += sizeof(HANDLER) + 2; if (jm->mode == JM_T_RAID01) @@ -43,7 +49,7 @@ else *buf = 0; - sprintf(ret, "%s_%s%s", HANDLER, name, buf); + sprintf(ret, "%s_%s%s", HANDLER, buf0, buf); } return ret;
signature.asc
Description: Digital signature