From 49d85d61685ba3c37b8ae991ed2b81616790123e Mon Sep 17 00:00:00 2001 From: Daniel Richard G Date: Tue, 17 May 2022 21:15:38 -0400 Subject: [PATCH] Rename g_file_open() to make r/w access explicit g_file_open() -> g_file_open_rw() --- common/os_calls.c | 2 +- common/os_calls.h | 2 +- fontdump/fontdump.c | 2 +- keygen/keygen.c | 2 +- sesman/lock_uds.c | 2 +- sesman/sesman.c | 8 ++++---- xrdp/xrdp.c | 10 +++++----- xrdp/xrdp_mm.c | 2 +- xrdp/xrdpwin.c | 12 ++++++------ 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index 1b3939034d..f41fc9d337 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -2162,7 +2162,7 @@ g_memcmp(const void *s1, const void *s2, int len) /*****************************************************************************/ /* returns -1 on error, else return handle or file descriptor */ int -g_file_open(const char *file_name) +g_file_open_rw(const char *file_name) { #if defined(_WIN32) return (int)CreateFileA(file_name, GENERIC_READ | GENERIC_WRITE, diff --git a/common/os_calls.h b/common/os_calls.h index a0818a2871..534478a437 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -119,7 +119,7 @@ int g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs, void g_random(char *data, int len); int g_abs(int i); int g_memcmp(const void *s1, const void *s2, int len); -int g_file_open(const char *file_name); +int g_file_open_rw(const char *file_name); int g_file_open_ex(const char *file_name, int aread, int awrite, int acreate, int atrunc); int g_file_open_ro(const char *file_name); diff --git a/fontdump/fontdump.c b/fontdump/fontdump.c index 03609cf05d..f439e09671 100644 --- a/fontdump/fontdump.c +++ b/fontdump/fontdump.c @@ -151,7 +151,7 @@ font_dump(void) g_snprintf(filename, 255, "%s-%d.fv1", g_font_name, g_font_size); msg("creating file %s", filename); g_file_delete(filename); - fd = g_file_open(filename); + fd = g_file_open_rw(filename); g_file_write(fd, "FNT1", 4); strlen1 = g_strlen(g_font_name); g_file_write(fd, g_font_name, strlen1); diff --git a/keygen/keygen.c b/keygen/keygen.c index e1c1e95c0e..9b477530b1 100644 --- a/keygen/keygen.c +++ b/keygen/keygen.c @@ -367,7 +367,7 @@ save_all(const char *e_data, int e_len, const char *n_data, int n_len, } } - fd = g_file_open(filename); + fd = g_file_open_rw(filename); if (fd != -1) { diff --git a/sesman/lock_uds.c b/sesman/lock_uds.c index cafc63666a..70b11bd662 100644 --- a/sesman/lock_uds.c +++ b/sesman/lock_uds.c @@ -87,7 +87,7 @@ lock_uds(const char *sockname) *p++ = '\0'; saved_umask = g_umask_hex(0x77); - fd = g_file_open(filename); + fd = g_file_open_rw(filename); g_umask_hex(saved_umask); if (fd < 0) { diff --git a/sesman/sesman.c b/sesman/sesman.c index 00c7fafae6..423e569bdc 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -777,15 +777,15 @@ main(int argc, char **argv) g_file_close(1); g_file_close(2); - if (g_file_open("/dev/null") < 0) + if (g_file_open_rw("/dev/null") < 0) { } - if (g_file_open("/dev/null") < 0) + if (g_file_open_rw("/dev/null") < 0) { } - if (g_file_open("/dev/null") < 0) + if (g_file_open_rw("/dev/null") < 0) { } } @@ -843,7 +843,7 @@ main(int argc, char **argv) { /* writing pid file */ char pid_s[32]; - int fd = g_file_open(pid_file); + int fd = g_file_open_rw(pid_file); if (-1 == fd) { diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index 7a355d4465..f588782ef0 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -579,7 +579,7 @@ main(int argc, char **argv) g_create_path(pid_file); /* make sure we can write to pid file */ - fd = g_file_open(pid_file); /* xrdp.pid */ + fd = g_file_open_rw(pid_file); /* xrdp.pid */ if (fd == -1) { @@ -638,7 +638,7 @@ main(int argc, char **argv) g_sleep(1000); /* write the pid to file */ pid = g_getpid(); - fd = g_file_open(pid_file); /* xrdp.pid */ + fd = g_file_open_rw(pid_file); /* xrdp.pid */ if (fd == -1) { @@ -657,15 +657,15 @@ main(int argc, char **argv) g_file_close(1); g_file_close(2); - if (g_file_open("/dev/null") < 0) + if (g_file_open_rw("/dev/null") < 0) { } - if (g_file_open("/dev/null") < 0) + if (g_file_open_rw("/dev/null") < 0) { } - if (g_file_open("/dev/null") < 0) + if (g_file_open_rw("/dev/null") < 0) { } diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index fc4296a7f4..bce36988ab 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -2686,7 +2686,7 @@ xrdp_mm_dump_jpeg(struct xrdp_mm *self, XRDP_ENC_DATA_DONE *enc_done) header.bytes_follow = enc_done->comp_bytes - (2 + pheader_bytes[0]); if (ii == 0) { - ii = g_file_open("/tmp/jpeg.beef.bin"); + ii = g_file_open_rw("/tmp/jpeg.beef.bin"); if (ii == -1) { ii = 0; diff --git a/xrdp/xrdpwin.c b/xrdp/xrdpwin.c index e54ca9b721..07d2edbe23 100644 --- a/xrdp/xrdpwin.c +++ b/xrdp/xrdpwin.c @@ -221,7 +221,7 @@ MyServiceMain(DWORD dwArgc, LPTSTR *lpszArgv) // int fd; // char text[256]; - // fd = g_file_open("c:\\temp\\xrdp\\log.txt"); + // fd = g_file_open_rw("c:\\temp\\xrdp\\log.txt"); // g_file_write(fd, "hi\r\n", 4); //event_han = RegisterEventSource(0, "xrdp"); //log_event(event_han, "hi xrdp log"); @@ -546,7 +546,7 @@ main(int argc, char **argv) if (!no_daemon) { /* make sure we can write to pid file */ - fd = g_file_open(pid_file); /* xrdp.pid */ + fd = g_file_open_rw(pid_file); /* xrdp.pid */ if (fd == -1) { @@ -586,9 +586,9 @@ main(int argc, char **argv) g_file_close(0); g_file_close(1); g_file_close(2); - g_file_open("/dev/null"); - g_file_open("/dev/null"); - g_file_open("/dev/null"); + g_file_open_rw("/dev/null"); + g_file_open_rw("/dev/null"); + g_file_open_rw("/dev/null"); /* end of daemonizing code */ } @@ -596,7 +596,7 @@ main(int argc, char **argv) { /* write the pid to file */ pid = g_getpid(); - fd = g_file_open(pid_file); /* xrdp.pid */ + fd = g_file_open_rw(pid_file); /* xrdp.pid */ if (fd == -1) {