Skip to content

Commit 5f26786

Browse files
committed
mkdir 长度检查 - dir.cpp
1 parent 449a05d commit 5f26786

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

dir.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ void mkdir(char *dirname){
4343
struct inode *inode;
4444
struct direct buf[BLOCKSIZ/(DIRSIZ+4)];
4545
unsigned int block;
46-
46+
if (strlen(dirname) > DIRSIZ)
47+
{
48+
printf("命名长度超过上限\n", dirname);
49+
return;
50+
}
4751
dirid= namei(dirname);
4852
if (dirid != -1){
4953
inode = iget(dirid);

0 commit comments

Comments
 (0)