Bug fix: short Rock Ridge names got stripped of trailing blanks when loaded
and written again to a follow-up session. Long names could lose inner blanks.
This commit is contained in:
parent
a30bd36a81
commit
0ab2b8260c
@ -302,7 +302,7 @@ int read_rr_NM(struct susp_sys_user_entry *nm, char **name, int *cont)
|
||||
*name = realloc(*name, strlen(*name) + nm->len_sue[0] - 5 + 1);
|
||||
strncat(*name, (char*)nm->data.NM.name, nm->len_sue[0] - 5);
|
||||
} else {
|
||||
*name = strcopy((char*)nm->data.NM.name, nm->len_sue[0] - 5);
|
||||
*name = iso_util_strcopy((char*)nm->data.NM.name, nm->len_sue[0] - 5);
|
||||
}
|
||||
if (*name == NULL) {
|
||||
return ISO_OUT_OF_MEM;
|
||||
@ -380,7 +380,7 @@ int read_rr_SL(struct susp_sys_user_entry *sl, char **dest, int *cont)
|
||||
/* we don't have to add the '/' */
|
||||
strncat(*dest, comp, len);
|
||||
} else {
|
||||
*dest = strcopy(comp, len);
|
||||
*dest = iso_util_strcopy(comp, len);
|
||||
}
|
||||
if (*dest == NULL) {
|
||||
return ISO_OUT_OF_MEM;
|
||||
|
@ -1381,6 +1381,10 @@ int iso_eaccess(const char *path)
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#ifdef NIX
|
||||
/* <<< Buggy and not used any more */
|
||||
|
||||
char *strcopy(const char *buf, size_t len)
|
||||
{
|
||||
char *str;
|
||||
@ -1401,24 +1405,37 @@ char *strcopy(const char *buf, size_t len)
|
||||
return str;
|
||||
}
|
||||
|
||||
char *iso_util_strcopy_untail(const char *buf, size_t len)
|
||||
#endif /* NIX */
|
||||
|
||||
|
||||
char *iso_util_strcopy(const char *buf, size_t len)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = malloc((len + 1) * sizeof(char));
|
||||
str = calloc(len + 1, 1);
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
strncpy(str, buf, len);
|
||||
str[len] = 0;
|
||||
str[len] = '\0';
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
char *iso_util_strcopy_untail(const char *buf, size_t len)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = iso_util_strcopy(buf, len);
|
||||
if (str == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
/* remove trailing spaces */
|
||||
for (len = len-1; len >= 0; --len) {
|
||||
if (str[len] != ' ')
|
||||
break;
|
||||
str[len] = 0;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -246,6 +246,9 @@ time_t iso_datetime_read_17(const uint8_t *buf);
|
||||
*/
|
||||
int iso_eaccess(const char *path);
|
||||
|
||||
#ifdef NIX
|
||||
/* <<< Buggy and not used any more */
|
||||
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
@ -255,6 +258,14 @@ int iso_eaccess(const char *path);
|
||||
*/
|
||||
char *strcopy(const char *buf, size_t len);
|
||||
|
||||
#endif /* NIX */
|
||||
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
*/
|
||||
char *iso_util_strcopy(const char *buf, size_t len);
|
||||
|
||||
/**
|
||||
* Copy up to \p len chars from \p buf and return this newly allocated
|
||||
* string. The new string is null-terminated.
|
||||
|
Loading…
Reference in New Issue
Block a user