Skip to content

Commit

Permalink
FIX: cmd_df 缓冲区溢出问题
Browse files Browse the repository at this point in the history
  • Loading branch information
frapples committed Sep 17, 2017
1 parent 51f5a21 commit 5ae6b27
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions shell_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,12 @@ int cmd_cp(int argc, char* argv[])
printf("操作失败!\n");
return 0;
}
int returnNumber = 100;
int readNumber = 100;
char *buf;
while(returnNumber == readNumber)
char buf[1024];
int c = fs_read(sourceFile, buf, sizeof(buf) - 1);
while(c > 0)
{
returnNumber = fs_read(sourceFile, buf, readNumber);
fs_write(targetFile,buf,returnNumber);
fs_write(targetFile, buf, c);
c = fs_read(sourceFile, buf, sizeof(buf) - 1);
}

fs_close(sourceFile);
Expand Down

0 comments on commit 5ae6b27

Please sign in to comment.