Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian Development (http://www.linux-archive.org/debian-development/)
-   -   Revert "Avoid string duplication calling dirname()" (http://www.linux-archive.org/debian-development/676905-revert-avoid-string-duplication-calling-dirname.html)

Cleber Rosa 06-25-2012 01:45 PM

Revert "Avoid string duplication calling dirname()"
 
Because dirname() may modify the path. See:

http://www.kernel.org/doc/man-pages/online/pages/man3/dirname.3.html

This fixes a segfault found while manually testing grubby on RHEL 5.

This reverts commit 54ff9d923f1dd90dde81e0e90e9448fdc52044c4.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
grubby.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grubby.c b/grubby.c
index 3c93729..afc90a6 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1309,7 +1309,7 @@ static int writeConfig(struct grubConfig * cfg, char * outName,

/* most likely the symlink is relative, so change our
directory to the dir of the symlink */
- rc = chdir(dirname(outName));
+ rc = chdir(dirname(strdupa(outName)));
do {
buf = alloca(len + 1);
rc = readlink(basename(outName), buf, len);
--
1.7.10.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

Cleber Rosa 06-25-2012 01:48 PM

Revert "Avoid string duplication calling dirname()"
 
On 06/25/2012 10:45 AM, Cleber Rosa wrote:

Because dirname() may modify the path. See:

http://www.kernel.org/doc/man-pages/online/pages/man3/dirname.3.html

This fixes a segfault found while manually testing grubby on RHEL 5.

This reverts commit 54ff9d923f1dd90dde81e0e90e9448fdc52044c4.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
grubby.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/grubby.c b/grubby.c
index 3c93729..afc90a6 100644
--- a/grubby.c
+++ b/grubby.c
@@ -1309,7 +1309,7 @@ static int writeConfig(struct grubConfig * cfg, char * outName,

/* most likely the symlink is relative, so change our

directory to the dir of the symlink */
- rc = chdir(dirname(outName));
+ rc = chdir(dirname(strdupa(outName)));
do {
buf = alloca(len + 1);
rc = readlink(basename(outName), buf, len);


Peter,

BTW, I know there has been a record number of releases, but if a 8.15
could be released soon with this fix it'd be great.


This is currently affecting our ability to test RHEL 5 systems.

Thanks a lot!
CR.

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

Adrian Perez de Castro 06-25-2012 02:12 PM

Revert "Avoid string duplication calling dirname()"
 
Hi,

Cleber Rosa <crosa@redhat.com> writes:

> Because dirname() may modify the path. See:
>
> http://www.kernel.org/doc/man-pages/online/pages/man3/dirname.3.html
>
> This fixes a segfault found while manually testing grubby on RHEL 5.
>
> This reverts commit 54ff9d923f1dd90dde81e0e90e9448fdc52044c4.

Ok, you are right in this, it looks like I had read the dirname()
manpage without paying attention to that detail.

This introduces back a memory leak -- which I know it is not a huge
issue provided that Grubby is not a long-running process. Nevertheless,
going through the code and fixing those would be desirable in the long
term (IMHO).

Regards,

--
Adrian Perez <aperez@igalia.com> - Sent from my toaster
Igalia - Free Software Engineering
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

Peter Jones 06-25-2012 02:34 PM

Revert "Avoid string duplication calling dirname()"
 
On 06/25/2012 10:12 AM, Adrian Perez de Castro wrote:


Ok, you are right in this, it looks like I had read the dirname()
manpage without paying attention to that detail.

This introduces back a memory leak -- which I know it is not a huge
issue provided that Grubby is not a long-running process. Nevertheless,
going through the code and fixing those would be desirable in the long
term (IMHO).


Yeah, you're right. I've pushed a fix upstream, though I kicked off an
8.15 build before you noticed this, so the fix will be in whenever 8.16
happens. It's a very minor problem, so I'm not too worried about getting
a fixed build done immediately.

--
Peter

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


All times are GMT. The time now is 09:21 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.