lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1355834283.18807.227.camel@deadeye.wl.decadent.org.uk>
Date:	Tue, 18 Dec 2012 12:38:03 +0000
From:	Ben Hutchings <ben@...adent.org.uk>
To:	Tomas Hozza <thozza@...hat.com>
Cc:	gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
	devel@...uxdriverproject.org, olaf@...fle.de, apw@...onical.com,
	jasowang@...hat.com, kys@...rosoft.com
Subject: Re: [PATCH 1/3] tools/hv: Fix for long file names from readdir

On Tue, 2012-12-18 at 03:06 -0500, Tomas Hozza wrote:
> ----- Original Message -----
> > > This is just for sanity. The value PATH_MAX was chosen after
> > > discussion
> > > with K. Y. Srinivasan and Olaf Hering instead of some "magic"
> > > number like
> > > 256 or 512.
> > 
> > PATH_MAX is a magic name.
> 
> It is defined in "limits.h". I would welcome some more constructive
> argumentation and critics.

It still bears no relation to any actual limit in the C library or Linux
kernel.  So it's no more valid than the previous number.

In the current context we're enumerating /sys/class/net and we know that
all the interface names in there are limited to IFNAMSIZ-1 = 15 (there
is also potentially "bonding_masters").  The longest path name we need
to use is definitely much shorter than even 256 bytes.

> > > > Using snprintf() is a good idea, but you need to check the return
> > > > value and handle the truncation case somehow.
> > > 
> > > By using PATH_MAX sized buffer there is no need for handling the
> > > truncation
> > > case.
> >  
> > You are claiming two contradictory things: sprintf() may overrun the
> > buffer, so we need the length check provided by snprintf(), but there
> > is no need to check for truncation because we know the length is
> > sufficient.
> 
> So what do you propose? How should it be solved?

	if (snprintf(dev_id, sizeof(dev_id), ...) >= sizeof(dev_id))
		continue;

Possibly logging a warning.

Ben.

-- 
Ben Hutchings
Life is like a sewer:
what you get out of it depends on what you put into it.

Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ