]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tftpd: fix/tidy up `open()` mode flags
authorViktor Szakats <commit@vsz.me>
Mon, 24 Nov 2025 13:51:18 +0000 (14:51 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 24 Nov 2025 21:33:22 +0000 (22:33 +0100)
- replace 0777 with `S_I*` macros.
- fix to not pass invalid flags on Windows.

Follow-up to 537987d8c66aac6ec96cde098ab45525e156b54e #19645

Closes #19671

tests/server/tftpd.c

index dd7291c7ceb0bbee1acf18ab3c5e28560b24434f..6631e2439b965de445b84ae9e9bd7dfb96ab35d1 100644 (file)
@@ -445,7 +445,15 @@ static ssize_t write_behind(struct testcase *test, int convert)
   if(!test->ofile) {
     char outfile[256];
     snprintf(outfile, sizeof(outfile), "%s/upload.%ld", logdir, test->testno);
-    test->ofile = open(outfile, O_CREAT|O_RDWR|CURL_O_BINARY, 0777);
+    test->ofile = open(outfile, O_CREAT | O_RDWR | CURL_O_BINARY,
+#ifdef _WIN32
+                       S_IREAD | S_IWRITE
+#else
+                       S_IRUSR | S_IWUSR | S_IXUSR |
+                       S_IRGRP | S_IWGRP | S_IXGRP |
+                       S_IROTH | S_IWOTH | S_IXOTH
+#endif
+                       );
     if(test->ofile == -1) {
       logmsg("Could not create and/or open file %s for upload!", outfile);
       return -1; /* failure! */