1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 08:26:52 +03:00
Commit Graph

5 Commits

Author SHA1 Message Date
kay.sievers@vrfy.org
993a633ab8 [PATCH] update to libsysfs 1.2.0 and add some stuff klib_fixup 2005-04-26 22:06:44 -07:00
ananth@in.ibm.com
656703759d [PATCH] more Libsysfs updates
On Thu, Mar 11, 2004 at 02:36:23PM +0100, Kay Sievers wrote:
> On Thu, 2004-03-11 at 15:02, Ananth N Mavinakayanahalli wrote:
> > On Thu, Mar 11, 2004 at 02:04:36PM +0100, Kay Sievers wrote:
> > > On Thu, Mar 11, 2004 at 11:53:50AM +0500, Ananth N Mavinakayanahalli wrote:
> > >
> > > > +#define safestrcpy(to, from)	strncpy(to, from, sizeof(to)-1)
> > > > +#define safestrcat(to, from)	strncat(to, from, sizeof(to) - strlen(to)-1)
> > >
> > > These strings are not terminated with '\0' if from is longer than
> > > the sizeof to.
> >
> > Did not do it on purpose as the "to" elements are either calloc'd or memset to
> > '0' explicitly in the library. Thats the reason I mentioned "scaled down" :)
>
> Ahh, sounds good.
>
> > > > +#define safestrncpy(to, from, maxsize) \
> > > > +do { \
> > > > +	to[maxsize-1] = '\0'; \
> > > > +	strncpy(to, from, maxsize-1); \
> > > > +} while (0)
> > > > +
> > > > +#define safestrncat(to, from, maxsize) \
> > > > +do { \
> > > > +	to[maxsize-1] = '\0'; \
> > > > +	strncat(to, from, maxsize - strlen(to)-1); \
> > > > +} while (0)
> > >
> > > We all expect a similar behavior like strncat/strncpy according to the
> > > names, but these macros are limiting by the target size and do not limit
> > > the count of chars copied.
> > > This is confusing I think and suggest using a different name like
> > > 'safestrcopymax()' or something.
> >
> > Good point.. will make the change
>
> Nice. I've had these *n* names too and I forgot about the logic and only
> 10 days later I introduced a ugly bug cause I can't limit the count of
> copied chars :)

Inlined is the patch for this... applies on the earlier _BIG_ patch.
2005-04-26 21:35:09 -07:00
ananth@in.ibm.com
d1fb871d99 [PATCH] Libsysfs updates
Please find attached a _BIG_ patch to update udev's libsysfs. Patch applies
on udev-021 and contains:

1. Updates to get udev's libsysfs to the latest (to be released) level.
2. Changes for C++ compatibility (use "char" and not "unsigned char"
	unless absolutely necessary).
3. More importantly, take care of buffer overflows. Libsysfs now uses a
        scaled down version of Kay's "safe" macros.

Tested using a usb-storage device.

I will send you a doc update shortly.
2005-04-26 21:35:09 -07:00
greg@kroah.com
df41554d99 [PATCH] fix up libsysfs header file usage to fix bug reports from users that have sysfsutils installed already. 2005-04-26 21:32:29 -07:00
greg@kroah.com
a638109dfa [PATCH] mv libsysfs/libsysfs.h to libsysfs/sysfs/libsysfs.h to make it easier to use. 2005-04-26 21:32:29 -07:00