RE: [PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Yue Zhang [mailto:yuezha@xxxxxxxxxxxxx]
> Sent: Thursday, June 26, 2014 2:09 PM
> To: KY Srinivasan; Haiyang Zhang; driverdev-devel@xxxxxxxxxxxxxxxxxxxxxx;
> linux-kernel@xxxxxxxxxxxxxxx; olaf@xxxxxxxxx; jasowang@xxxxxxxxxx;
> apw@xxxxxxxxxxxxx
> Cc: Dexuan Cui; Thomas Shao
> Subject: [PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon
> 
> From: Yue Zhang <yuezha@xxxxxxxxxxxxx>
> 
> hv_fcopy_daemon fails to overwrite a file if the target file already exits.
> 
> Add O_TRUNC flag on opening.
> 
> Signed-off-by: Yue Zhang <yuezha@xxxxxxxxxxxxx>
> ---
>  tools/hv/hv_fcopy_daemon.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
> index fba1c75..01eee6b 100644
> --- a/tools/hv/hv_fcopy_daemon.c
> +++ b/tools/hv/hv_fcopy_daemon.c
> @@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
>  		}
>  	}
> 
> -	target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC,
> 0744);
> +	target_fd = open(target_fname,
> +				O_RDWR | O_CREAT | O_TRUNC |
Please align O_RDWR to align with the first argument (target_fname). 

K. Y

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux