Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Bug fixes. #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion groupcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ static int parse_subject(sd_bus_message *m, struct subject *subject)
return r;

if (strlen(value) >= MAX_NAME_SIZE)
return r;
return -EINVAL;

strncpy(subject->data.s.session_id, value, MAX_NAME_SIZE);
subject->data.s.session_id[MAX_NAME_SIZE-1] = '\0';

r = sd_bus_message_exit_container(m);
if (r < 0)
Expand All @@ -375,6 +376,7 @@ static int parse_subject(sd_bus_message *m, struct subject *subject)
return -EINVAL;

strncpy(subject->data.s.session_id, value, MAX_NAME_SIZE);
subject->data.s.session_id[MAX_NAME_SIZE-1] = '\0';

r = sd_bus_message_exit_container(m);
if (r < 0)
Expand Down
12 changes: 6 additions & 6 deletions test_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, char *argv[])
int r = -1, i;
const char *action_id;
const char *name = NULL;
bool *allowed;
bool *allowed = false;
gid_t supplementary_groups[argc];

if (argc < 2) {
Expand Down Expand Up @@ -92,24 +92,24 @@ int main(int argc, char *argv[])
r = sd_bus_message_open_container(msg, SD_BUS_TYPE_ARRAY, "{sv}");
if (r < 0)
goto end;

r = sd_bus_message_open_container(msg, SD_BUS_TYPE_DICT_ENTRY, "sv");
if (r < 0)
goto end;

r = sd_bus_message_append(msg, "s", "name");
if (r < 0)
goto end;

r = sd_bus_message_append(msg, "v", "s", name);
if (r < 0)
goto end;

/* dict entry */
r = sd_bus_message_close_container(msg);
if (r < 0)
goto end;

/* array */
r = sd_bus_message_close_container(msg);
if (r < 0)
Expand All @@ -135,7 +135,7 @@ int main(int argc, char *argv[])
r = sd_bus_message_append(msg, "s", "");
if (r < 0)
goto end;

r = sd_bus_call(bus, msg, 0, NULL, &reply);
if (r < 0) {
fprintf(stderr, "D-Bus method call failed: %s\n", strerror(-r));
Expand Down