* [RFC PATCH 1/2] fs: fix path_check_prereq()
@ 2011-10-18 9:48 Antony Pavlov
2011-10-18 9:48 ` [RFC PATCH 2/2] fs: fix chdir() Antony Pavlov
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Antony Pavlov @ 2011-10-18 9:48 UTC (permalink / raw)
To: barebox
This patch makes impossible the situations than path_check_prereq() can make
'return 0' without changing errno.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
fs/fs.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 7d65ec8..714fc9b 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -293,9 +293,11 @@ static int path_check_prereq(const char *path, unsigned int flags)
struct stat s;
unsigned int m;
+ errno = 0;
+
if (stat(path, &s)) {
if (flags & S_UB_DOES_NOT_EXIST)
- return 0;
+ goto out;
errno = -ENOENT;
goto out;
}
@@ -306,7 +308,7 @@ static int path_check_prereq(const char *path, unsigned int flags)
}
if (flags == S_UB_EXISTS)
- return 0;
+ goto out;
m = s.st_mode;
@@ -325,7 +327,6 @@ static int path_check_prereq(const char *path, unsigned int flags)
goto out;
}
- errno = 0;
out:
return errno;
}
--
1.7.6.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFC PATCH 2/2] fs: fix chdir()
2011-10-18 9:48 [RFC PATCH 1/2] fs: fix path_check_prereq() Antony Pavlov
@ 2011-10-18 9:48 ` Antony Pavlov
2011-10-18 10:13 ` [RFC PATCH 1/2] fs: fix path_check_prereq() Sascha Hauer
2011-10-19 9:51 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Antony Pavlov @ 2011-10-18 9:48 UTC (permalink / raw)
To: barebox
chdir() allocates memory using mormalise_path(). But if path_check_prereq()
returns error than memory isn't freed.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
fs/fs.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 714fc9b..f42ca36 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -347,8 +347,9 @@ int chdir(const char *pathname)
strcpy(cwd, p);
- free(p);
out:
+ free(p);
+
return errno;
}
EXPORT_SYMBOL(chdir);
--
1.7.6.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH 1/2] fs: fix path_check_prereq()
2011-10-18 9:48 [RFC PATCH 1/2] fs: fix path_check_prereq() Antony Pavlov
2011-10-18 9:48 ` [RFC PATCH 2/2] fs: fix chdir() Antony Pavlov
@ 2011-10-18 10:13 ` Sascha Hauer
2011-10-19 9:51 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2011-10-18 10:13 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Tue, Oct 18, 2011 at 01:48:44PM +0400, Antony Pavlov wrote:
> This patch makes impossible the situations than path_check_prereq() can make
> 'return 0' without changing errno.
Both applied to master. Thanks for fixing this.
Sascha
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> fs/fs.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fs.c b/fs/fs.c
> index 7d65ec8..714fc9b 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -293,9 +293,11 @@ static int path_check_prereq(const char *path, unsigned int flags)
> struct stat s;
> unsigned int m;
>
> + errno = 0;
> +
> if (stat(path, &s)) {
> if (flags & S_UB_DOES_NOT_EXIST)
> - return 0;
> + goto out;
> errno = -ENOENT;
> goto out;
> }
> @@ -306,7 +308,7 @@ static int path_check_prereq(const char *path, unsigned int flags)
> }
>
> if (flags == S_UB_EXISTS)
> - return 0;
> + goto out;
>
> m = s.st_mode;
>
> @@ -325,7 +327,6 @@ static int path_check_prereq(const char *path, unsigned int flags)
> goto out;
> }
>
> - errno = 0;
> out:
> return errno;
> }
> --
> 1.7.6.3
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH 1/2] fs: fix path_check_prereq()
2011-10-18 9:48 [RFC PATCH 1/2] fs: fix path_check_prereq() Antony Pavlov
2011-10-18 9:48 ` [RFC PATCH 2/2] fs: fix chdir() Antony Pavlov
2011-10-18 10:13 ` [RFC PATCH 1/2] fs: fix path_check_prereq() Sascha Hauer
@ 2011-10-19 9:51 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2011-10-19 9:51 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Tue, Oct 18, 2011 at 01:48:44PM +0400, Antony Pavlov wrote:
> This patch makes impossible the situations than path_check_prereq() can make
> 'return 0' without changing errno.
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> fs/fs.c | 7 ++++---
> 1 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fs.c b/fs/fs.c
> index 7d65ec8..714fc9b 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -293,9 +293,11 @@ static int path_check_prereq(const char *path, unsigned int flags)
> struct stat s;
> unsigned int m;
>
> + errno = 0;
> +
> if (stat(path, &s)) {
> if (flags & S_UB_DOES_NOT_EXIST)
> - return 0;
> + goto out;
Wow. You broke mkdir.
stat() changes errno, so path_check_prereq returns an error value
when S_UB_DOES_NOT_EXIST is set and a file does not exist.
Sascha
> errno = -ENOENT;
> goto out;
> }
> @@ -306,7 +308,7 @@ static int path_check_prereq(const char *path, unsigned int flags)
> }
>
> if (flags == S_UB_EXISTS)
> - return 0;
> + goto out;
>
> m = s.st_mode;
>
> @@ -325,7 +327,6 @@ static int path_check_prereq(const char *path, unsigned int flags)
> goto out;
> }
>
> - errno = 0;
> out:
> return errno;
> }
> --
> 1.7.6.3
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-19 9:51 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-18 9:48 [RFC PATCH 1/2] fs: fix path_check_prereq() Antony Pavlov
2011-10-18 9:48 ` [RFC PATCH 2/2] fs: fix chdir() Antony Pavlov
2011-10-18 10:13 ` [RFC PATCH 1/2] fs: fix path_check_prereq() Sascha Hauer
2011-10-19 9:51 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox