Util-Linux package development
 help / color / mirror / Atom feed
From: Bernhard Voelker <mail@bernhard-voelker.de>
To: Karel Zak <kzak@redhat.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 11/15] prlimit: avoid segfault due to	array-out-of-bounds error
Date: Wed, 16 Nov 2011 15:10:44 +0100	[thread overview]
Message-ID: <4EC3C464.1070401@bernhard-voelker.de> (raw)
In-Reply-To: <20111116125655.GI7916@nb.net.home>

On 11/16/2011 01:56 PM, Karel Zak wrote:
>> Example:
>> >  $ prlimit -l -l -l -l -l -l -l -l -l -l -l -l -l -l -l -l -l -l -l
>> >  RESOURCE DESCRIPTION                         SOFT   HARD UNITS
>> >  MEMLOCK  max locked-in-memory address space 65536 262144 bytes
>> >  MEMLOCK  max locked-in-memory address space 65536 262144 bytes
>> >  ...
>> >  Segmentation fault
>   Ah.. stupid bug.
>
>> >  Use the lims array in a more direct way, i.e. the index is limit id.
>> >  Initialize lims array and adapt option parsing in main() accordingly.
>> >  do_prlimits() and show_limits(): loop over all MAX_RESOURCES in the
>> >  lims array.
>   It means that users cannot control order of the printed and modified
>   resources. We prefer in all our new utils that output is fully
>   controlled by users -- only this is a way how you can create stable
>   and robust scripts.
>
>   I have replaced the array with list (see include/list.h). This
>   solution makes the code more readable and robust.
>
>   # ./prlimit --data --nofile
>   RESOURCE DESCRIPTION                   SOFT      HARD UNITS
>   DATA     max data size            unlimited unlimited bytes
>   NOFILE   max amount of open files      1001      3000

thanks, using a list is even cooler!

With my solution, you couldn't display a limit before and after
changing it in the same call like it is possible now:

prlimit -n -n1000: -n -n:1000 -n
RESOURCE DESCRIPTION              SOFT HARD UNITS
NOFILE   max amount of open files 1024 8192
NOFILE   max amount of open files 1000 8192
NOFILE   max amount of open files 1000 1000

Have a nice day,
Berny


      reply	other threads:[~2011-11-16 14:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-14  1:48 [PATCH 11/15] prlimit: avoid segfault due to array-out-of-bounds error Bernhard Voelker
2011-11-16 12:56 ` Karel Zak
2011-11-16 14:10   ` Bernhard Voelker [this message]

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=4EC3C464.1070401@bernhard-voelker.de \
    --to=mail@bernhard-voelker.de \
    --cc=kzak@redhat.com \
    --cc=util-linux@vger.kernel.org \
    /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