public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roland Dreier <roland@topspin.com>
To: Paul Jackson <pj@sgi.com>
Cc: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR
Date: Tue, 28 Sep 2004 08:29:39 -0700	[thread overview]
Message-ID: <52mzzacsyk.fsf@topspin.com> (raw)
In-Reply-To: <20040927234333.7cceff47.pj@sgi.com> (Paul Jackson's message of "Mon, 27 Sep 2004 23:43:33 -0700")

Your patch is buggy:

+	length += snprintf (buffer + length, max(buffer_size - length, 0),
 			    "DEVICE=/proc/bus/usb/%03d/%03d",
 			    usb_dev->bus->busnum, usb_dev->devnum);

snprintf() returns the number of characters that would be written not
counting the trailing NUL.  So the next env var is going to be
concatenated with this one.

It's precisely this sort of easy-to-make off-by-one bug that convinces
me the hotplug environment variable handling needs to be wrapped up in
a helper macro or function.

Thanks,
  Roland

  reply	other threads:[~2004-09-28 15:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-27 16:31 [PATCH][0/2] [RESEND] Hotplug variable patches Roland Dreier
2004-09-27 16:31 ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Roland Dreier
2004-09-27 16:31   ` [PATCH][2/2] [RESEND] USB: use HOTPLUG_ENV_VAR in core/usb.c Roland Dreier
2004-09-27 20:10   ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Paul Jackson
2004-09-27 22:10     ` Roland Dreier
2004-09-28  6:43       ` Paul Jackson
2004-09-28 15:29         ` Roland Dreier [this message]
2004-09-28 16:00           ` Paul Jackson
2004-09-28 16:13             ` Roland Dreier
2004-09-28 21:56               ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2004-09-27 16:59 [PATCH][0/2] [RESEND] Hotplug variable patches Roland Dreier
2004-09-27 16:59 ` [PATCH][1/2] [RESEND] kobject: add HOTPLUG_ENV_VAR Roland Dreier

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=52mzzacsyk.fsf@topspin.com \
    --to=roland@topspin.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pj@sgi.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