make sure to close urandom file in jb_server_client_assign_unique_name

This commit is contained in:
hippoz 2022-12-26 23:34:27 +02:00
parent e20e5ff3af
commit fb2ea18aad
Signed by: hippoz
GPG key ID: 56C4E02A85F2FBED

View file

@ -112,6 +112,8 @@ int jb_server_client_assign_unique_name(struct jb_server *s, int i)
if (fread(&id, 1, sizeof(uint32_t), urandom_file) != sizeof(uint32_t)) { if (fread(&id, 1, sizeof(uint32_t), urandom_file) != sizeof(uint32_t)) {
return -1; return -1;
} }
fclose(urandom_file);
char *name = malloc(sizeof(char) * 16); char *name = malloc(sizeof(char) * 16);
if (!name) { if (!name) {
return -1; return -1;
@ -224,7 +226,10 @@ int jb_server_client_process_message(struct jb_server *s, int i, uint8_t *data,
.data_len = data_len, .data_len = data_len,
}; };
TRYST(wire_parse_message(&ctx, &msg)); if (wire_parse_message(&ctx, &msg) < 0) {
printf("parsing failed\n");
return -1;
}
wire_message_field_t *destination_field = &msg.fields[DBUS_HEADER_FIELD_DESTINATION]; wire_message_field_t *destination_field = &msg.fields[DBUS_HEADER_FIELD_DESTINATION];
wire_message_field_t *member_field = &msg.fields[DBUS_HEADER_FIELD_MEMBER]; wire_message_field_t *member_field = &msg.fields[DBUS_HEADER_FIELD_MEMBER];