Hi all,
I found two possible bug in cmd_mkfile:
- File not closed
- Memory not deallocated
Patch is attached. Let me know.
Best regards,
Manuele
=== modified file 'uspace/app/bdsh/cmds/modules/mkfile/mkfile.c'
--- uspace/app/bdsh/cmds/modules/mkfile/mkfile.c 2016-03-29 19:36:43 +0000
+++ uspace/app/bdsh/cmds/modules/mkfile/mkfile.c 2016-04-22 10:46:01 +0000
@@ -164,12 +164,16 @@
if (create_sparse && file_size > 0) {
const char byte = 0x00;
- if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0)
+ if ((rc2 = lseek(fd, file_size - 1, SEEK_SET)) < 0) {
+ close(fd);
goto error;
+ }
rc2 = write(fd, &byte, sizeof(char));
- if (rc2 < 0)
+ if (rc2 < 0) {
+ close(fd);
goto error;
+ }
return CMD_SUCCESS;
}
@@ -186,6 +190,7 @@
if (rc <= 0) {
printf("%s: Error writing file (%d).\n", cmdname, errno);
close(fd);
+ free(buffer);
return CMD_FAILURE;
}
total_written += rc;
_______________________________________________
HelenOS-devel mailing list
[email protected]
http://lists.modry.cz/listinfo/helenos-devel