All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.de.marchi@gmail.com>
To: Michal Marek <mmarek@suse.com>
Cc: linux-modules <linux-modules@vger.kernel.org>
Subject: Re: [PATCH] libkmod: Handle long lines in /proc/modules
Date: Mon, 20 Jun 2016 10:41:18 -0300	[thread overview]
Message-ID: <CAKi4VAJXUrovNoHCZzarZE1Udm6Rz-CePGOO9YyrfsN+Ag30rw@mail.gmail.com> (raw)
In-Reply-To: <5767ECB7.8040203@suse.com>

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.

Lucas De Marchi

  reply	other threads:[~2016-06-20 13:41 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 [this message]
2016-06-20 14:54       ` Michal Marek
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=CAKi4VAJXUrovNoHCZzarZE1Udm6Rz-CePGOO9YyrfsN+Ag30rw@mail.gmail.com \
    --to=lucas.de.marchi@gmail.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=mmarek@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.