mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

Integer underflow in websockets.c

Open dbstf opened this issue 3 months ago • 1 comments

The properties uid and gid of the struct lws_context_creation_info are defined as type uid_t and gid_t, which both resolve to unsigned int, respectively.

websockets.c: In function ‘mosq_websockets_init’:
websockets.c:702:20: warning: unsigned conversion from ‘int’ to ‘gid_t’ {aka ‘unsigned int’} changes value from ‘-1’ to ‘4294967295’ [-Wsign-conversion]
  702 |         info.gid = -1;
      |                    ^
websockets.c:703:20: warning: unsigned conversion from ‘int’ to ‘uid_t’ {aka ‘unsigned int’} changes value from ‘-1’ to ‘4294967295’ [-Wsign-conversion]
  703 |         info.uid = -1;
      |    

The current behavior in websockets.c is most likely undesired, I guess. What would be appropriate values here?

dbstf avatar Sep 22 '25 16:09 dbstf

The libwebsockets documentation explicitly says to set them to -1 if not used, so there's no real option to do otherwise.

ralight avatar Sep 26 '25 15:09 ralight