linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Marek <mmarek@suse.com>
To: Lucas De Marchi <lucas.de.marchi@gmail.com>
Cc: linux-modules <linux-modules@vger.kernel.org>
Subject: Re: [PATCH] libkmod: Handle long lines in /proc/modules
Date: Mon, 20 Jun 2016 16:54:50 +0200	[thread overview]
Message-ID: <576803BA.8030801@suse.com> (raw)
In-Reply-To: <CAKi4VAJXUrovNoHCZzarZE1Udm6Rz-CePGOO9YyrfsN+Ag30rw@mail.gmail.com>

On 2016-06-20 15:41, Lucas De Marchi wrote:
> On Mon, Jun 20, 2016 at 10:16 AM, Michal Marek <mmarek@suse.com> wrote:
>> On 2016-06-20 14:55, Lucas De Marchi wrote:
>>> On Fri, Jun 17, 2016 at 11:04 AM, Michal Marek <mmarek@suse.com> wrote:
>>>> Also, the buffer could be shrinked now, so that we do not use that much
>>>> space on stack. Not sure if this is of interest or not. I left it as is.
>>>
>>> Yep, I think it's reasonable to be 64 bytes since it's the maximum
>>> length of a module name
>>
>> OK. In kmod_module_get_size(), the buffer needs to be larger, though.
>>
>>
>>>> diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
>>>> index 1460c6746cc4..25dcda7667b7 100644
>>>> --- a/libkmod/libkmod-module.c
>>>> +++ b/libkmod/libkmod-module.c
>>>> @@ -1660,13 +1660,14 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx,
>>>>                 struct kmod_module *m;
>>>>                 struct kmod_list *node;
>>>>                 int err;
>>>> +               size_t len = strlen(line);
>>>>                 char *saveptr, *name = strtok_r(line, " \t", &saveptr);
>>>>
>>>>                 err = kmod_module_new_from_name(ctx, name, &m);
>>>>                 if (err < 0) {
>>>>                         ERR(ctx, "could not get module from name '%s': %s\n",
>>>>                                 name, strerror(-err));
>>>> -                       continue;
>>>> +                       goto eat_line;
>>>
>>> I think it would be better to "eat line" before anything else, above
>>> kmod_module_new_from_name(). So you don't need to change the flow
>>> here.
>>
>> Sure, but then we would need two buffers, because name is a pointer into
>> line.
> 
> oh, right. Thinking again, I'm ok with your version.

Shall I post a version that reduces the size of the buffer, or are you
going to apply my patch as is?

Thanks,
Michal

  reply	other threads:[~2016-06-20 14:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-17 14:04 [PATCH] libkmod: Handle long lines in /proc/modules Michal Marek
2016-06-20 12:55 ` Lucas De Marchi
2016-06-20 13:16   ` Michal Marek
2016-06-20 13:41     ` Lucas De Marchi
2016-06-20 14:54       ` Michal Marek [this message]
2016-06-21 21:06         ` Lucas De Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=576803BA.8030801@suse.com \
    --to=mmarek@suse.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.de.marchi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).