[fpc-devel] I get duplicate GUIDs under Linux

Mattias Gärtner nc-gaertnma at netcologne.de
Thu May 29 15:24:41 CEST 2008


Zitat von Graeme Geldenhuys <graemeg.lists at gmail.com>:

> 2008/5/29 Mattias Gärtner <nc-gaertnma at netcologne.de>:
> >
> > It would hurt a lot *not* installing the patch. The bigger problem is that
> the
> > other distributions including windows, Mac OS X, BSD, ... server must now
> > install the blacklist too. I guess non debian systems now have bigger
> problems
> > than debian.
>
> Yeah, I google'd the debian fiasco to get a better understanding.
> It's a *huge* screw-up!
>
> >> I gather that you can reproduce the issue and also get stuck on 1021?
> >
> > Yes. 1019
> >
> > And then pango gave:
> > (testproject:27449): Pango-WARNING **: error opening config file
> > '/etc/pango/pangorc': Too many open files
> > Apparently CreateGUID is buggy and should not be used under Linux.
>
> I need to convert existing data to our new system, so I am in need of
> a lot of GUID's quickly. At least in the interim I have a workaround
> via the 'libuuid' unit, otherwise I would be in big trouble.
>
> How can I force my fpc to use the 'random' option, instead of
> '.../random/uuid'?  Or must I copy and paste the code from RTL into my
> own function?

If the GUID are used in security contexts, then you *must* wait and gather some
real random numbers.
Otherwise you can simply call Randomize once at the start of the program and
use:

Procedure GetRandomBytes(Var Buf; NBytes : Integer);
Var
  I : Integer;
  P : PByte;
begin
  P:=@Buf;
  For I:=0 to NBytes-1 do
    P[i]:=Random(256);
end;

  Randomize; // call this only once every few seconds
  for i:=0 to 5000000 do begin
    GetRandomBytes(GUID,SizeOf(Guid));

This gave me 5 mil unique guids.

Mattias




More information about the fpc-devel mailing list