Skip to content

Commit

Permalink
NULL after fclose()
Browse files Browse the repository at this point in the history
  • Loading branch information
jesperpedersen committed Jan 18, 2025
1 parent 0ab77ad commit da88a3a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ master_key(char* password, bool generate_pwd, int pwd_length, int32_t output_for
}

fclose(file);
file = NULL;

chmod(&buf[0], S_IRUSR | S_IWUSR);
printf("Master Key stored into %s\n", &buf[0]);
Expand All @@ -462,6 +463,7 @@ master_key(char* password, bool generate_pwd, int pwd_length, int32_t output_for
if (file)
{
fclose(file);
file = NULL;
}

return 1;
Expand Down Expand Up @@ -632,6 +634,7 @@ add_user(char* users_path, char* username, char* password, bool generate_pwd, in
free(verify);

fclose(users_file);
users_file = NULL;

end_t = time(NULL);

Expand Down Expand Up @@ -673,6 +676,7 @@ add_user(char* users_path, char* username, char* password, bool generate_pwd, in
if (users_file)
{
fclose(users_file);
users_file = NULL;
}

pgagroal_management_create_outcome_failure(j, 1, &outcome);
Expand Down Expand Up @@ -874,7 +878,9 @@ update_user(char* users_path, char* username, char* password, bool generate_pwd,
free(verify);

fclose(users_file);
users_file = NULL;
fclose(users_file_tmp);
users_file_tmp = NULL;

rename(tmpfilename, users_path);

Expand Down Expand Up @@ -918,11 +924,13 @@ update_user(char* users_path, char* username, char* password, bool generate_pwd,
if (users_file)
{
fclose(users_file);
users_file = NULL;
}

if (users_file_tmp)
{
fclose(users_file_tmp);
users_file_tmp = NULL;
}

if (strlen(tmpfilename) > 0)
Expand Down Expand Up @@ -1030,7 +1038,9 @@ remove_user(char* users_path, char* username, int32_t output_format)
}

fclose(users_file);
users_file = NULL;
fclose(users_file_tmp);
users_file_tmp = NULL;

rename(tmpfilename, users_path);

Expand Down Expand Up @@ -1064,11 +1074,13 @@ remove_user(char* users_path, char* username, int32_t output_format)
if (users_file)
{
fclose(users_file);
users_file = NULL;
}

if (users_file_tmp)
{
fclose(users_file_tmp);
users_file_tmp = NULL;
}

if (strlen(tmpfilename) > 0)
Expand Down Expand Up @@ -1130,6 +1142,7 @@ list_users(char* users_path, int32_t output_format)

fclose(users_file);
users_file = NULL;
users_file = NULL;

end_t = time(NULL);

Expand Down Expand Up @@ -1161,6 +1174,7 @@ list_users(char* users_path, int32_t output_format)
if (users_file)
{
fclose(users_file);
users_file = NULL;
}

return 1;
Expand Down Expand Up @@ -1216,4 +1230,4 @@ create_response(char* users_path, struct json* json, struct json** response)
pgagroal_json_destroy(r);

return 1;
}
}

0 comments on commit da88a3a

Please sign in to comment.