[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Making dpkg run at a reasonable speed



I've made dpkg run at reasonable speeds on merulo.  Here's how you can
do it too.

Put the following text in strncpy.c:

#define _GNU_SOURCE
#include <string.h>

char *strncpy(char *dest, const char *src, size_t n)
{
	unsigned int m = strnlen(src, n);
	memcpy(dest, src, m);
	if (m < n) {
		memset(dest + m, 0, n - m);
	}
	return dest;
}

Then compile it with:

gcc -W -Wall -ansi -pedantic -fPIC -shared -o strncpy.so strncpy.c

(I like my warnings.)

Now, become root using your favourite method and:

mv strncpy.so /etc
echo /etc/strncpy.so >>/etc/ld.so.preload

Now dpkg is pseudo-fixed.  The real fix comes in two parts: glibc will be
updated to make strncpy not suck so much for this case, and dpkg will be
fixed to not use strncpy.  I've Considered strncpy Harmful for a while,
and this has only confirmed my earlier thoughts :-)

Oh, if anyone spots a bug in the strncpy implementation above, do shout;
I knocked it up quickly and it WorksForMe so far.

-- 
Revolutions do not require corporate support.



Reply to: