Commit Diff


commit - c5331d4c606ecb36f1a7d62aa112cb094f93f5d4
commit + fd740a5299ccd8f3dea9fa2233c96817b5445791
blob - ad6c43f7d9ce8b6c7bd8b37929b8cc68bd181ca4
blob + 160b28df61d87a2b8f230ddd850025fe665d2d06
--- FICS/fics_addplayer.c
+++ FICS/fics_addplayer.c
@@ -40,6 +40,7 @@
 #include "command.h"
 #include "config.h"
 #include "fics_getsalt.h"
+#include "ficsmain.h"
 #include "playerdb.h"
 #include "utils.h"
 
@@ -60,12 +61,17 @@ add_handle_to_list(const char *handle)
 {
 	FILE	*fp;
 	char	 path[1024];
+	int	 fd;
 
 	snprintf(path, sizeof path, "%s/admin", DEFAULT_LISTS);
 
-	if ((fp = fopen(path, "a")) == NULL) {
+	if ((fd = open(path, g_open_flags[0], g_open_modes)) < 0) {
 		warn("%s: unable to open %s", __func__, path);
 		return;
+	} else if ((fp = fdopen(fd, "a")) == NULL) {
+		warn("%s: unable to open %s", __func__, path);
+		close(fd);
+		return;
 	}
 
 	fprintf(fp, "%s\n", handle);