dmraid/dmraid-1.0.0.rc13-jm_termination.patch

24 lines
703 B
Diff

Index: 1.0.0.rc13/lib/format/ataraid/jm.c
===================================================================
--- 1.0.0.rc13.orig/lib/format/ataraid/jm.c
+++ 1.0.0.rc13/lib/format/ataraid/jm.c
@@ -28,10 +28,15 @@ static char *name(struct lib_context *lc
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;
+ 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)