diff options
author | Renato Botelho <renato@netgate.com> | 2016-05-03 08:53:59 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-05-03 08:53:59 -0300 |
commit | 501575fb1206644a3ea8c2cd64a81084745445cc (patch) | |
tree | e07e5ad3f3ff6f6cf2841dd2d2eb0dcb0e54521a /sys/fs/msdosfs/msdosfs_conv.c | |
parent | 91f599cbc0d103dd112a2472b589573724b8d70a (diff) | |
parent | 04acf11bf47629b82fc88ce0e6d6dc642b1e641b (diff) | |
download | FreeBSD-src-501575fb1206644a3ea8c2cd64a81084745445cc.zip FreeBSD-src-501575fb1206644a3ea8c2cd64a81084745445cc.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'sys/fs/msdosfs/msdosfs_conv.c')
-rw-r--r-- | sys/fs/msdosfs/msdosfs_conv.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c index 6671afc..5e6c20d 100644 --- a/sys/fs/msdosfs/msdosfs_conv.c +++ b/sys/fs/msdosfs/msdosfs_conv.c @@ -678,7 +678,9 @@ win2unixfn(nbp, wep, chksum, pmp) switch (code) { case 0: *np = '\0'; - mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); + if (mbnambuf_write(nbp, name, + (wep->weCnt & WIN_CNT) - 1) != 0) + return -1; return chksum; case '/': *np = '\0'; @@ -696,7 +698,9 @@ win2unixfn(nbp, wep, chksum, pmp) switch (code) { case 0: *np = '\0'; - mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); + if (mbnambuf_write(nbp, name, + (wep->weCnt & WIN_CNT) - 1) != 0) + return -1; return chksum; case '/': *np = '\0'; @@ -714,7 +718,9 @@ win2unixfn(nbp, wep, chksum, pmp) switch (code) { case 0: *np = '\0'; - mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); + if (mbnambuf_write(nbp, name, + (wep->weCnt & WIN_CNT) - 1) != 0) + return -1; return chksum; case '/': *np = '\0'; @@ -728,7 +734,8 @@ win2unixfn(nbp, wep, chksum, pmp) cp += 2; } *np = '\0'; - mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1); + if (mbnambuf_write(nbp, name, (wep->weCnt & WIN_CNT) - 1) != 0) + return -1; return chksum; } @@ -1030,7 +1037,7 @@ mbnambuf_init(struct mbnambuf *nbp) * This only penalizes portions of substrings that contain more than * WIN_CHARS bytes when they are first encountered. */ -void +int mbnambuf_write(struct mbnambuf *nbp, char *name, int id) { char *slot; @@ -1041,7 +1048,7 @@ mbnambuf_write(struct mbnambuf *nbp, char *name, int id) printf("msdosfs: non-decreasing id: id %d, last id %d\n", id, nbp->nb_last_id); #endif - return; + return (EINVAL); } /* Will store this substring in a WIN_CHARS-aligned slot. */ @@ -1052,17 +1059,24 @@ mbnambuf_write(struct mbnambuf *nbp, char *name, int id) #ifdef MSDOSFS_DEBUG printf("msdosfs: file name length %zu too large\n", newlen); #endif - return; + return (ENAMETOOLONG); } /* Shift suffix upwards by the amount length exceeds WIN_CHARS. */ - if (count > WIN_CHARS && nbp->nb_len != 0) + if (count > WIN_CHARS && nbp->nb_len != 0) { + if ((id * WIN_CHARS + count + nbp->nb_len) > + sizeof(nbp->nb_buf)) + return (ENAMETOOLONG); + bcopy(slot + WIN_CHARS, slot + count, nbp->nb_len); + } /* Copy in the substring to its slot and update length so far. */ bcopy(name, slot, count); nbp->nb_len = newlen; nbp->nb_last_id = id; + + return (0); } /* |