[PATCH] lib: fwts_dump: check error return on mkdir
IvanHu
ivan.hu at canonical.com
Thu May 16 04:10:13 UTC 2013
On 05/07/2013 08:35 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Coverity CID #997311, Unchecked return value from library
>
> We should really check that mkdir failed or not rather than
> assume it worked OK.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_dump.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_dump.c b/src/lib/src/fwts_dump.c
> index cbf6598..f3ccc15 100644
> --- a/src/lib/src/fwts_dump.c
> +++ b/src/lib/src/fwts_dump.c
> @@ -248,9 +248,12 @@ int fwts_dump_info(fwts_framework *fw, const char *path)
> if (path == NULL)
> path = "./";
>
> - if (access(path, F_OK) != 0)
> - mkdir(path, 0777);
> -
> + if (access(path, F_OK) != 0) {
> + if (mkdir(path, 0777) < 0) {
> + fprintf(stderr, "Cannot mkdir %s.\n", path);
> + return FWTS_ERROR;
> + }
> + }
>
> if (dump_readme(path) != FWTS_OK)
> fprintf(stderr, "Failed to dump README.txt.\n");
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list