svn commit: r352873 - stable/11/sbin/fsck_msdosfs
Xin LI
delphij at FreeBSD.org
Sun Sep 29 20:08:15 UTC 2019
Author: delphij
Date: Sun Sep 29 20:08:14 2019
New Revision: 352873
URL: https://svnweb.freebsd.org/changeset/base/352873
Log:
MFC r351802:
Correct overflow logic in fullpath().
Obtained from: OpenBSD
Modified:
stable/11/sbin/fsck_msdosfs/dir.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sbin/fsck_msdosfs/dir.c
==============================================================================
--- stable/11/sbin/fsck_msdosfs/dir.c Sun Sep 29 20:05:48 2019 (r352872)
+++ stable/11/sbin/fsck_msdosfs/dir.c Sun Sep 29 20:08:14 2019 (r352873)
@@ -168,20 +168,24 @@ fullpath(struct dosDirEntry *dir)
char *cp, *np;
int nl;
- cp = namebuf + sizeof namebuf - 1;
- *cp = '\0';
- do {
+ cp = namebuf + sizeof namebuf;
+ *--cp = '\0';
+
+ for(;;) {
np = dir->lname[0] ? dir->lname : dir->name;
nl = strlen(np);
- if ((cp -= nl) <= namebuf + 1)
+ if (cp <= namebuf + 1 + nl) {
+ *--cp = '?';
break;
+ }
+ cp -= nl;
memcpy(cp, np, nl);
+ dir = dir->parent;
+ if (!dir)
+ break;
*--cp = '/';
- } while ((dir = dir->parent) != NULL);
- if (dir)
- *--cp = '?';
- else
- cp++;
+ }
+
return cp;
}
More information about the svn-src-all
mailing list