[spam] software responsibility

Karl gmkarl at gmail.com
Thu Nov 4 12:34:33 PDT 2021


1501

k my interpretation of the condition for forwarding the defaults to the
backend a second time in libusb_init was incorrect

in f7084 by harbulot, the condition is changed from (!ctx) to (ctx ||
!usbi_default_context)

this results in forwarding the values when there is a ctx, which wasn't
previously the case.

there might be a logic error here regarding default ctxs?  i'll increase
git's diff output

1513

1517

ok

in libusb_init, ctx is the pointer-to-a-pointer passed in.  nowadays if it
is null, a default context is supposedly used.
meanwhile _ctx with its preceding underscore, is a zero initialised block
of memory that will be the new ctx, allocated on the heap.  it looks like
this memory is allocated even if a default context might be reused.

it looks like a logic bug may be present.  it appears that
usbi_default_context is uninitialised, so likely default_context_refcnt
should be checked rather than it.

1521

default_context_refcnt is also uninitialised.  it would make sense to fix
these.

I wonder if c supports static local variables.  I guess I should maybe know
that whether it's relevant or not.

looks like they are.  1524.  should be accessed with lock I imagine.  I
think there's some existing static locked stuff, unsure, can see what
degree of protection against initialisation order they're using.

I think they have a list of contexts maybe?  unsure?

oh great there's a default_context_lock

and an active_contexts_list

interestingly the check already compares the content of the structure with
zero.  I wonder if things are auto filled with zeros.

it just contains two pointers, prev and next.

maybe websearching can help me

1528

the internet does not yet appear to believe that happens.  maybe they use
some compile flag, i'll glance at them.

they pass -std=gnu11

maybe i'll glance through c11 stuff and websearch more

1531

ok at journaldev.com I found "The default value of the initialization of
the Static variable is zero (0)."  maybe I can find something more
authoritative

ok I found a second source saying static and global variables are
initialised to zero if not initialised explicitly.  so I better reconsider
this code, which looks much better now.

1534
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/html
Size: 3604 bytes
Desc: not available
URL: <https://lists.cpunks.org/pipermail/cypherpunks/attachments/20211104/69564389/attachment.txt>


More information about the cypherpunks mailing list