lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 11 Mar 2014 14:30:02 -0600
From:	Andreas Dilger <adilger@...ger.ca>
To:	"Darrick J. Wong" <darrick.wong@...cle.com>
Cc:	tytso@....edu, linux-ext4@...r.kernel.org
Subject: Re: [PATCH 01/49] create_inode: clean up return mess in do_write_internal

On Mar 11, 2014, at 12:54 AM, Darrick J. Wong <darrick.wong@...cle.com> wrote:
> do_write_internal returns errno when ext2 library calls fail; since
> errno only reflects the outcome of the last C library call, this will
> result in confused callers.  Eliminate the naked return since
> this results in an undefined return value.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@...cle.com>
> ---
> misc/create_inode.c |   17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
> 
> 
> diff --git a/misc/create_inode.c b/misc/create_inode.c
> index cf4a58f..647480c 100644
> --- a/misc/create_inode.c
> +++ b/misc/create_inode.c
> @@ -353,14 +353,14 @@ errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
> 	if (retval == 0) {
> 		com_err(__func__, 0, "The file '%s' already exists\n", dest);
> 		close(fd);
> -		return errno;
> +		return retval;
> 	}

This seems a bit strange.  It looks like an error return, but it will
actually return "0" since this branch is only entered if retval == 0.
Should this return an explicit error value here?

Cheers, Andreas

> 	retval = ext2fs_new_inode(current_fs, cwd, 010755, 0, &newfile);
> 	if (retval) {
> 		com_err(__func__, retval, 0);
> 		close(fd);
> -		return errno;
> +		return retval;
> 	}
> #ifdef DEBUGFS
> 	printf("Allocated inode: %u\n", newfile);
> @@ -372,7 +372,7 @@ errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
> 		if (retval) {
> 			com_err(__func__, retval, "while expanding directory");
> 			close(fd);
> -			return errno;
> +			return retval;
> 		}
> 		retval = ext2fs_link(current_fs, cwd, dest, newfile,
> 					EXT2_FT_REG_FILE);
> @@ -412,12 +412,15 @@ errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
> 	if ((retval = ext2fs_write_new_inode(current_fs, newfile, &inode))) {
> 		com_err(__func__, retval, "while creating inode %u", newfile);
> 		close(fd);
> -		return errno;
> +		return retval;
> 	}
> 	if (inode.i_flags & EXT4_INLINE_DATA_FL) {
> 		retval = ext2fs_inline_data_init(current_fs, newfile);
> -		if (retval)
> -			return;
> +		if (retval) {
> +			com_err("copy_file", retval, 0);
> +			close(fd);
> +			return retval;
> +		}
> 	}
> 	if (LINUX_S_ISREG(inode.i_mode)) {
> 		if (statbuf.st_blocks < statbuf.st_size / S_BLKSIZE) {
> @@ -434,7 +437,7 @@ errcode_t do_write_internal(ext2_ino_t cwd, const char *src, const char *dest)
> 	}
> 	close(fd);
> 
> -	return 0;
> +	return retval;
> }
> 
> /* Copy files from source_dir to fs */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ