Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix (harmless) memory leaks & replace magic number with constant #309

Merged
merged 1 commit into from
Jan 16, 2024
Merged
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
6 changes: 3 additions & 3 deletions pamu2fcfg/pamu2fcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,13 @@ int main(int argc, char *argv[]) {
parse_args(argc, argv, &args);
fido_init(args.debug ? FIDO_DEBUG : 0);

devlist = fido_dev_info_new(64);
devlist = fido_dev_info_new(DEVLIST_LEN);
if (!devlist) {
fprintf(stderr, "error: fido_dev_info_new failed\n");
goto err;
}

r = fido_dev_info_manifest(devlist, 64, &ndevs);
r = fido_dev_info_manifest(devlist, DEVLIST_LEN, &ndevs);
if (r != FIDO_OK) {
fprintf(stderr, "Unable to discover device(s), %s (%d)\n", fido_strerr(r),
r);
Expand All @@ -489,7 +489,7 @@ int main(int argc, char *argv[]) {
fflush(stderr);
sleep(FREQUENCY);

r = fido_dev_info_manifest(devlist, 64, &ndevs);
r = fido_dev_info_manifest(devlist, DEVLIST_LEN, &ndevs);
if (r != FIDO_OK) {
fprintf(stderr, "\nUnable to discover device(s), %s (%d)",
fido_strerr(r), r);
Expand Down
10 changes: 5 additions & 5 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,13 +1155,13 @@ int do_authentication(const cfg_t *cfg, const device_t *devices,
#endif
memset(&pk, 0, sizeof(pk));

devlist = fido_dev_info_new(64);
devlist = fido_dev_info_new(DEVLIST_LEN);
if (!devlist) {
debug_dbg(cfg, "Unable to allocate devlist");
goto out;
}

r = fido_dev_info_manifest(devlist, 64, &ndevs);
r = fido_dev_info_manifest(devlist, DEVLIST_LEN, &ndevs);
if (r != FIDO_OK) {
debug_dbg(cfg, "Unable to discover device(s), %s (%d)", fido_strerr(r), r);
goto out;
Expand All @@ -1171,7 +1171,7 @@ int do_authentication(const cfg_t *cfg, const device_t *devices,

debug_dbg(cfg, "Device max index is %zu", ndevs);

authlist = calloc(64 + 1, sizeof(fido_dev_t *));
authlist = calloc(DEVLIST_LEN + 1, sizeof(fido_dev_t *));
if (!authlist) {
debug_dbg(cfg, "Unable to allocate authenticator list");
goto out;
Expand Down Expand Up @@ -1267,13 +1267,13 @@ int do_authentication(const cfg_t *cfg, const device_t *devices,

fido_dev_info_free(&devlist, ndevs);

devlist = fido_dev_info_new(64);
devlist = fido_dev_info_new(DEVLIST_LEN);
if (!devlist) {
debug_dbg(cfg, "Unable to allocate devlist");
goto out;
}

r = fido_dev_info_manifest(devlist, 64, &ndevs);
r = fido_dev_info_manifest(devlist, DEVLIST_LEN, &ndevs);
if (r != FIDO_OK) {
debug_dbg(cfg, "Unable to discover device(s), %s (%d)", fido_strerr(r),
r);
Expand Down
2 changes: 2 additions & 0 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#define DEFAULT_ORIGIN_PREFIX "pam://"
#define SSH_ORIGIN "ssh:"

#define DEVLIST_LEN 64

typedef struct {
unsigned max_devs;
int manual;
Expand Down
Loading