FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 11-04-2009, 09:27 PM
David Cantrell
 
Default Correctly initialize modopts in loader (#531932).

Under certain conditions, modopts is never initialized. This patch
fixes up that while preserving the existing functionality introduced
with 29e18c35.
---
loader/modules.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/loader/modules.c b/loader/modules.c
index d5129b7..f61f680 100644
--- a/loader/modules.c
+++ b/loader/modules.c
@@ -117,16 +117,18 @@ static void addOption(const char *module, const char *option) {
}

if (found) {
- modopts[i].options = realloc(modopts[i].options,
- sizeof(modopts[i].options) *
- (modopts[i].numopts + 1));
- modopts[i].options[modopts[i].numopts - 1] = strdup(option);
- modopts[i].options[modopts[i].numopts] = NULL;
- } else {
- modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
- modopts[nummodopts].name = strdup(module);
- modopts[nummodopts].numopts = 1;
- modopts[nummodopts++].options = NULL;
+ if (modopts == NULL) {
+ modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
+ modopts[nummodopts].name = strdup(module);
+ modopts[nummodopts].numopts = 1;
+ modopts[nummodopts++].options = NULL;
+ } else {
+ modopts[i].options = realloc(modopts[i].options,
+ sizeof(modopts[i].options) *
+ (modopts[i].numopts + 1));
+ modopts[i].options[modopts[i].numopts - 1] = strdup(option);
+ modopts[i].options[modopts[i].numopts] = NULL;
+ }
}

return;
--
1.6.5.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 11-04-2009, 09:42 PM
David Lehman
 
Default Correctly initialize modopts in loader (#531932).

On Wed, 2009-11-04 at 12:27 -1000, David Cantrell wrote:
> Under certain conditions, modopts is never initialized. This patch
> fixes up that while preserving the existing functionality introduced
> with 29e18c35.
> ---
> loader/modules.c | 22 ++++++++++++----------
> 1 files changed, 12 insertions(+), 10 deletions(-)

ACK

>
> diff --git a/loader/modules.c b/loader/modules.c
> index d5129b7..f61f680 100644
> --- a/loader/modules.c
> +++ b/loader/modules.c
> @@ -117,16 +117,18 @@ static void addOption(const char *module, const char *option) {
> }
>
> if (found) {
> - modopts[i].options = realloc(modopts[i].options,
> - sizeof(modopts[i].options) *
> - (modopts[i].numopts + 1));
> - modopts[i].options[modopts[i].numopts - 1] = strdup(option);
> - modopts[i].options[modopts[i].numopts] = NULL;
> - } else {
> - modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
> - modopts[nummodopts].name = strdup(module);
> - modopts[nummodopts].numopts = 1;
> - modopts[nummodopts++].options = NULL;
> + if (modopts == NULL) {
> + modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
> + modopts[nummodopts].name = strdup(module);
> + modopts[nummodopts].numopts = 1;
> + modopts[nummodopts++].options = NULL;
> + } else {
> + modopts[i].options = realloc(modopts[i].options,
> + sizeof(modopts[i].options) *
> + (modopts[i].numopts + 1));
> + modopts[i].options[modopts[i].numopts - 1] = strdup(option);
> + modopts[i].options[modopts[i].numopts] = NULL;
> + }
> }
>
> return;

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 11-05-2009, 08:06 AM
Ales Kozumplik
 
Default Correctly initialize modopts in loader (#531932).

On 11/04/2009 11:27 PM, David Cantrell wrote:

Under certain conditions, modopts is never initialized. This patch
fixes up that while preserving the existing functionality introduced
with 29e18c35.
---
loader/modules.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/loader/modules.c b/loader/modules.c
index d5129b7..f61f680 100644
--- a/loader/modules.c
+++ b/loader/modules.c
@@ -117,16 +117,18 @@ static void addOption(const char *module, const char *option) {
}

if (found) {
- modopts[i].options = realloc(modopts[i].options,
- sizeof(modopts[i].options) *
- (modopts[i].numopts + 1));
- modopts[i].options[modopts[i].numopts - 1] = strdup(option);
- modopts[i].options[modopts[i].numopts] = NULL;
- } else {
- modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
- modopts[nummodopts].name = strdup(module);
- modopts[nummodopts].numopts = 1;
- modopts[nummodopts++].options = NULL;
+ if (modopts == NULL) {
+ modopts = realloc(modopts, sizeof(*modopts) * (nummodopts + 1));
+ modopts[nummodopts].name = strdup(module);
+ modopts[nummodopts].numopts = 1;
+ modopts[nummodopts++].options = NULL;
+ } else {
+ modopts[i].options = realloc(modopts[i].options,
+ sizeof(modopts[i].options) *
+ (modopts[i].numopts + 1));
+ modopts[i].options[modopts[i].numopts - 1] = strdup(option);
+ modopts[i].options[modopts[i].numopts] = NULL;
+ }
}

return;


Hi again David,

I was looking at this issue yesterday and I just took a look at your
patch. I am a bit confused: The code in the new revision will do nothing
in case a module of given name is not found in the table. If we assume
that nummodopts is initially 0, nothing ever gets added and the table
will remain empty -- is that what we want?


Also: why nummodopts is initially -1 (that has nothing to do with your
patch though, just a question)? Is that because we don't want
mlLoadModule calls to modify the table before mlInitModuleConfig is called?


Thank you,

Ales

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

Thread Tools




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

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org