View Issue Details

IDProjectCategoryView StatusLast Update
0037889FPCRTLpublic2020-10-08 14:43
ReporterFr0sT Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformAllOSLinux 
Product Version3.3.1 
Fixed in Version3.2.1 
Summary0037889: [patch] Get rid of magic constant for mode in FpOpen
DescriptionCurrently FpOpen (function that creates and opens files on Unix-es) uses magic constant 438 which is 666 octal which is "rwrwrw" (absolutely not obvious). Suggested patch replaces the number with proper constant defined as combination of system flags
TagsNo tags attached.
Fixed in Revision47064
FPCOldBugId
FPCTarget3.2.2
Attached Files

Activities

Fr0sT

2020-10-08 14:22

reporter  

fpopen.diff (1,210 bytes)   
 rtl/unix/bunxovl.inc | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/rtl/unix/bunxovl.inc b/rtl/unix/bunxovl.inc
index 12025aad32..c5774ea3a3 100644
--- a/rtl/unix/bunxovl.inc
+++ b/rtl/unix/bunxovl.inc
@@ -248,10 +248,16 @@ begin
 end;
 {$endif}
 
+const
+  { read/write permission for everyone }
+  MODE_FPOPEN = S_IWUSR OR S_IRUSR OR
+                S_IWGRP OR S_IRGRP OR
+                S_IWOTH OR S_IROTH;
+
 Function  FpOpen    (path : pChar; flags : cInt):cInt; {$ifdef VER2_0}inline;{$endif}
 
 begin
- FpOpen:=FpOpen(path,flags,438);
+ FpOpen:=FpOpen(path,flags,MODE_FPOPEN);
 end;
 
 Function  FpOpen    (const path : RawByteString; flags : cInt):cInt; {$ifdef VER2_0}inline;{$endif}
@@ -259,14 +265,14 @@ var
   SystemPath: RawByteString;
 Begin
   SystemPath:=ToSingleByteFileSystemEncodedFileName(path);
-  FpOpen:=FpOpen(pchar(SystemPath),flags,438);
+  FpOpen:=FpOpen(pchar(SystemPath),flags,MODE_FPOPEN);
 end;
 
 Function  FpOpen    (path : String; flags : cInt):cInt;
 
 begin
  path:=path+#0;
- FpOpen:=FpOpen(@path[1],flags,438);
+ FpOpen:=FpOpen(@path[1],flags,MODE_FPOPEN);
 end;
 
 Function  FpOpen    (path : String; flags : cInt; Mode: TMode):cInt;
fpopen.diff (1,210 bytes)   

Michael Van Canneyt

2020-10-08 14:43

administrator   ~0126145

Applied, thank you !

Issue History

Date Modified Username Field Change
2020-10-08 14:22 Fr0sT New Issue
2020-10-08 14:22 Fr0sT File Added: fpopen.diff
2020-10-08 14:43 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-10-08 14:43 Michael Van Canneyt Status new => resolved
2020-10-08 14:43 Michael Van Canneyt Resolution open => fixed
2020-10-08 14:43 Michael Van Canneyt Fixed in Version => 3.2.1
2020-10-08 14:43 Michael Van Canneyt Fixed in Revision => 47064
2020-10-08 14:43 Michael Van Canneyt FPCTarget => 3.2.2
2020-10-08 14:43 Michael Van Canneyt Note Added: 0126145