Lines 634-639
win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
Link Here
|
634 |
u_int8_t *np, name[WIN_CHARS * 3 + 1]; |
634 |
u_int8_t *np, name[WIN_CHARS * 3 + 1]; |
635 |
u_int16_t code; |
635 |
u_int16_t code; |
636 |
int i; |
636 |
int i; |
|
|
637 |
int ret; |
637 |
|
638 |
|
638 |
if ((wep->weCnt&WIN_CNT) > howmany(WIN_MAXLEN, WIN_CHARS) |
639 |
if ((wep->weCnt&WIN_CNT) > howmany(WIN_MAXLEN, WIN_CHARS) |
639 |
|| !(wep->weCnt&WIN_CNT)) |
640 |
|| !(wep->weCnt&WIN_CNT)) |
Lines 658-664
win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
Link Here
|
658 |
switch (code) { |
659 |
switch (code) { |
659 |
case 0: |
660 |
case 0: |
660 |
*np = '\0'; |
661 |
*np = '\0'; |
661 |
mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
662 |
ret = mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
|
|
663 |
if (ret < 0) |
664 |
return (-1); |
662 |
return chksum; |
665 |
return chksum; |
663 |
case '/': |
666 |
case '/': |
664 |
*np = '\0'; |
667 |
*np = '\0'; |
Lines 676-682
win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
Link Here
|
676 |
switch (code) { |
679 |
switch (code) { |
677 |
case 0: |
680 |
case 0: |
678 |
*np = '\0'; |
681 |
*np = '\0'; |
679 |
mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
682 |
ret = mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
|
|
683 |
if (ret < 0) |
684 |
return (-1); |
680 |
return chksum; |
685 |
return chksum; |
681 |
case '/': |
686 |
case '/': |
682 |
*np = '\0'; |
687 |
*np = '\0'; |
Lines 694-700
win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
Link Here
|
694 |
switch (code) { |
699 |
switch (code) { |
695 |
case 0: |
700 |
case 0: |
696 |
*np = '\0'; |
701 |
*np = '\0'; |
697 |
mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
702 |
ret = mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
|
|
703 |
if (ret < 0) |
704 |
return (-1); |
698 |
return chksum; |
705 |
return chksum; |
699 |
case '/': |
706 |
case '/': |
700 |
*np = '\0'; |
707 |
*np = '\0'; |
Lines 708-714
win2unixfn(struct mbnambuf *nbp, struct winentry *wep, int chksum,
Link Here
|
708 |
cp += 2; |
715 |
cp += 2; |
709 |
} |
716 |
} |
710 |
*np = '\0'; |
717 |
*np = '\0'; |
711 |
mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
718 |
ret = mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); |
|
|
719 |
if (ret < 0) |
720 |
return (-1); |
712 |
return chksum; |
721 |
return chksum; |
713 |
} |
722 |
} |
714 |
|
723 |
|
Lines 1005-1011
mbnambuf_init(struct mbnambuf *nbp)
Link Here
|
1005 |
* This only penalizes portions of substrings that contain more than |
1014 |
* This only penalizes portions of substrings that contain more than |
1006 |
* WIN_CHARS bytes when they are first encountered. |
1015 |
* WIN_CHARS bytes when they are first encountered. |
1007 |
*/ |
1016 |
*/ |
1008 |
void |
1017 |
int |
1009 |
mbnambuf_write(struct mbnambuf *nbp, char *name, int id) |
1018 |
mbnambuf_write(struct mbnambuf *nbp, char *name, int id) |
1010 |
{ |
1019 |
{ |
1011 |
char *slot; |
1020 |
char *slot; |
Lines 1016-1022
mbnambuf_write(struct mbnambuf *nbp, char *name, int id)
Link Here
|
1016 |
printf("msdosfs: non-decreasing id: id %d, last id %d\n", |
1025 |
printf("msdosfs: non-decreasing id: id %d, last id %d\n", |
1017 |
id, nbp->nb_last_id); |
1026 |
id, nbp->nb_last_id); |
1018 |
#endif |
1027 |
#endif |
1019 |
return; |
1028 |
return (-EINVAL); |
1020 |
} |
1029 |
} |
1021 |
|
1030 |
|
1022 |
/* Will store this substring in a WIN_CHARS-aligned slot. */ |
1031 |
/* Will store this substring in a WIN_CHARS-aligned slot. */ |
Lines 1027-1043
mbnambuf_write(struct mbnambuf *nbp, char *name, int id)
Link Here
|
1027 |
#ifdef MSDOSFS_DEBUG |
1036 |
#ifdef MSDOSFS_DEBUG |
1028 |
printf("msdosfs: file name length %zu too large\n", newlen); |
1037 |
printf("msdosfs: file name length %zu too large\n", newlen); |
1029 |
#endif |
1038 |
#endif |
1030 |
return; |
1039 |
return (-ENOMEM); |
1031 |
} |
1040 |
} |
1032 |
|
1041 |
|
1033 |
/* Shift suffix upwards by the amount length exceeds WIN_CHARS. */ |
1042 |
/* Shift suffix upwards by the amount length exceeds WIN_CHARS. */ |
1034 |
if (count > WIN_CHARS && nbp->nb_len != 0) |
1043 |
if (count > WIN_CHARS && nbp->nb_len != 0) |
|
|
1044 |
{ |
1045 |
if (((slot - nbp->nb_buf) + count + nbp->nb_len) > sizeof(nbp->nb_buf)) |
1046 |
return (-ENOMEM); |
1047 |
|
1035 |
bcopy(slot + WIN_CHARS, slot + count, nbp->nb_len); |
1048 |
bcopy(slot + WIN_CHARS, slot + count, nbp->nb_len); |
|
|
1049 |
} |
1036 |
|
1050 |
|
1037 |
/* Copy in the substring to its slot and update length so far. */ |
1051 |
/* Copy in the substring to its slot and update length so far. */ |
1038 |
bcopy(name, slot, count); |
1052 |
bcopy(name, slot, count); |
1039 |
nbp->nb_len = newlen; |
1053 |
nbp->nb_len = newlen; |
1040 |
nbp->nb_last_id = id; |
1054 |
nbp->nb_last_id = id; |
|
|
1055 |
|
1056 |
return (0); |
1041 |
} |
1057 |
} |
1042 |
|
1058 |
|
1043 |
/* |
1059 |
/* |