Closed Bug 74046 Opened 24 years ago Closed 23 years ago

Can't create temp files on windows with access mode 600

Categories

(NSPR :: NSPR, defect)

4.0.2
x86
Windows NT
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: cavin, Assigned: larryh)

References

Details

Temp files are created and removed when sending messages. However, these temp files are created with mode 644 which others can read on windows even though the code meant to create them with mode 600 (only creator can read and write). Here is the call stack when such files are to be created: PR_Open(const char * 0x07e46a08, int 42, int 384) line 341 + 17 bytes FileImpl::Open(FileImpl * const 0x07e4692c, const nsFileSpec & {...}, int 42, int 384) line 278 + 34 bytes FileImpl::FileImpl(const nsFileSpec & {...}, int 42, int 384) line 151 + 24 bytes NS_NewIOFileStream(nsISupports * * 0x0012bc38, const nsFileSpec & {...}, int 42, int 384) line 743 + 39 bytes nsOutputFileStream::nsOutputFileStream(const nsFileSpec & {...}, int 42, int 384, unsigned int 1) line 602 + 21 bytes nsMsgComposeAndSend::GatherMimeAttachments() line 612 + 56 bytes nsMsgComposeAndSend::HackAttachments(const nsMsgAttachmentData * 0x00000000, const nsMsgAttachedFile * 0x00000000) line 2294 + 8 bytes nsMsgComposeAndSend::Init(nsIMsgIdentity * 0x04b7c130, nsMsgCompFields * 0x0778ed70, nsFileSpec * 0x00000000, int 0, int 0, int 4, nsIMsgDBHdr * 0x00000000, const char * 0x05999cb8, const char * 0x00000000, unsigned int 0, const nsMsgAttachmentData * 0x00000000, const nsMsgAttachedFile * 0x00000000) line 2630 + 16 bytes nsMsgComposeAndSend::CreateAndSendMessage(nsMsgComposeAndSend * const 0x07e39d80, nsIEditorShell * 0x00000000, nsIMsgIdentity * 0x04b7c130, nsIMsgCompFields * 0x0778ed70, int 0, int 0, int 4, nsIMsgDBHdr * 0x00000000, const char * 0x05999cb8, const char * 0x00000000, unsigned int 0, const nsMsgAttachmentData * 0x00000000, const nsMsgAttachedFile * 0x00000000, void * ...) line 3508 nsMsgCompose::_SendMsg(int 4, nsIMsgIdentity * 0x04b7c130, int 1) line 618 + 129 bytes nsMsgCompose::SendMsg(nsMsgCompose * const 0x0778ee30, int 4, nsIMsgIdentity * 0x04b7c130) line 705 + 20 bytes XPTC_InvokeByIndex(nsISupports * 0x0778ee30, unsigned int 7, unsigned int 2, nsXPTCVariant * 0x0012c44c) line 139 nsXPCWrappedNativeClass::CallWrappedMethod(JSContext * 0x05b44200, nsXPCWrappedNative * 0x0778e960, const XPCNativeMemberDescriptor * 0x0778ea9c, nsXPCWrappedNativeClass::CallMode CALL_METHOD, unsigned int 2, long * 0x061dc610, long * 0x0012c634) line 934 + 42 bytes WrappedNative_CallMethod(JSContext * 0x05b44200, JSObject * 0x040e86c0, unsigned int 2, long * 0x061dc610, long * 0x0012c634) line 250 + 34 bytes js_Invoke(JSContext * 0x05b44200, unsigned int 2, unsigned int 0) line 781 + 23 bytes js_Interpret(JSContext * 0x05b44200, long * 0x0012d3b4) line 2674 + 15 bytes js_Invoke(JSContext * 0x05b44200, unsigned int 1, unsigned int 2) line 798 + 13 bytes nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJSClass * const 0x050fd150, nsXPCWrappedJS * 0x0776dfc0, unsigned short 5, const nsXPTMethodInfo * 0x03f48b98, nsXPTCMiniVariant * 0x0012d81c) line 874 + 21 bytes nsXPCWrappedJS::CallMethod(nsXPCWrappedJS * const 0x0776dfc0, unsigned short 5, const nsXPTMethodInfo * 0x03f48b98, nsXPTCMiniVariant * 0x0012d81c) line 432 PrepareAndDispatch(nsXPTCStubBase * 0x0776dfc0, unsigned int 5, unsigned int * 0x0012d8cc, unsigned int * 0x0012d8bc) line 100 + 31 bytes SharedStub() line 124 XPTC_InvokeByIndex(nsISupports * 0x0776dfc0, unsigned int 5, unsigned int 1, nsXPTCVariant * 0x0012da70) line 139 nsXPCWrappedNativeClass::CallWrappedMethod(JSContext * 0x05b44200, nsXPCWrappedNative * 0x077a6e70, const XPCNativeMemberDescriptor * 0x047c6d24, nsXPCWrappedNativeClass::CallMode CALL_METHOD, unsigned int 1, long * 0x061dc4b8, long * 0x0012dc58) line 934 + 42 bytes WrappedNative_CallMethod(JSContext * 0x05b44200, JSObject * 0x061d58d0, unsigned int 1, long * 0x061dc4b8, long * 0x0012dc58) line 250 + 34 bytes js_Invoke(JSContext * 0x05b44200, unsigned int 1, unsigned int 0) line 781 + 23 bytes js_Interpret(JSContext * 0x05b44200, long * 0x0012e9d8) line 2674 + 15 bytes js_Invoke(JSContext * 0x05b44200, unsigned int 1, unsigned int 2) line 798 + 13 bytes js_InternalInvoke(JSContext * 0x05b44200, JSObject * 0x061d5ca8, long 102587576, unsigned int 0, unsigned int 1, long * 0x0012eb70, long * 0x0012eb00) line 870 + 20 bytes JS_CallFunctionValue(JSContext * 0x05b44200, JSObject * 0x061d5ca8, long 102587576, unsigned int 1, long * 0x0012eb70, long * 0x0012eb00) line 3299 + 31 bytes nsJSContext::CallEventHandler(nsJSContext * const 0x05b46780, void * 0x061d5ca8, void * 0x061d5cb8, unsigned int 1, void * 0x0012eb70, int * 0x0012eb6c, int 0) line 940 + 33 bytes nsJSEventListener::HandleEvent(nsIDOMEvent * 0x07818e84) line 154 + 64 bytes nsEventListenerManager::HandleEventSubType(nsListenerStruct * 0x06d32980, nsIDOMEvent * 0x07818e84, nsIDOMEventTarget * 0x06d32f28, unsigned int 8, unsigned int 7) line 916 + 19 bytes nsEventListenerManager::HandleEvent(nsIPresContext * 0x05061ee0, nsEvent * 0x0012f43c, nsIDOMEvent * * 0x0012f2ec, nsIDOMEventTarget * 0x06d32f28, unsigned int 7, nsEventStatus * 0x0012f484) line 1844 + 39 bytes nsXULElement::HandleDOMEvent(nsXULElement * const 0x06d32f20, nsIPresContext * 0x05061ee0, nsEvent * 0x0012f43c, nsIDOMEvent * * 0x0012f2ec, unsigned int 1, nsEventStatus * 0x0012f484) line 3634 PresShell::HandleDOMEventWithTarget(PresShell * const 0x05d00d50, nsIContent * 0x06d32f20, nsEvent * 0x0012f43c, nsEventStatus * 0x0012f484) line 5108 + 39 bytes nsMenuFrame::Execute() line 1401 nsMenuFrame::HandleEvent(nsMenuFrame * const 0x040df908, nsIPresContext * 0x05061ee0, nsGUIEvent * 0x0012f884, nsEventStatus * 0x0012f778) line 378 PresShell::HandleEventInternal(nsEvent * 0x0012f884, nsIView * 0x07802030, unsigned int 1, nsEventStatus * 0x0012f778) line 5076 + 41 bytes PresShell::HandleEvent(PresShell * const 0x05d00d54, nsIView * 0x07802030, nsGUIEvent * 0x0012f884, nsEventStatus * 0x0012f778, int 0, int & 1) line 4996 + 25 bytes nsView::HandleEvent(nsView * const 0x07802030, nsGUIEvent * 0x0012f884, unsigned int 8, nsEventStatus * 0x0012f778, int 0, int & 1) line 372 nsView::HandleEvent(nsView * const 0x077e4ac0, nsGUIEvent * 0x0012f884, unsigned int 8, nsEventStatus * 0x0012f778, int 0, int & 1) line 345 nsView::HandleEvent(nsView * const 0x07809e80, nsGUIEvent * 0x0012f884, unsigned int 8, nsEventStatus * 0x0012f778, int 0, int & 1) line 345 nsView::HandleEvent(nsView * const 0x05064540, nsGUIEvent * 0x0012f884, unsigned int 28, nsEventStatus * 0x0012f778, int 1, int & 1) line 345 nsViewManager::DispatchEvent(nsViewManager * const 0x05061de0, nsGUIEvent * 0x0012f884, nsEventStatus * 0x0012f778) line 1982 HandleEvent(nsGUIEvent * 0x0012f884) line 68 nsWindow::DispatchEvent(nsWindow * const 0x05060ee4, nsGUIEvent * 0x0012f884, nsEventStatus & nsEventStatus_eIgnore) line 688 + 10 bytes nsWindow::DispatchWindowEvent(nsGUIEvent * 0x0012f884) line 709 nsWindow::DispatchMouseEvent(unsigned int 301, nsPoint * 0x00000000 {x=??? y=???}) line 3983 + 21 bytes ChildWindow::DispatchMouseEvent(unsigned int 301, nsPoint * 0x00000000 {x=??? y=???}) line 4193 nsWindow::ProcessMessage(unsigned int 514, unsigned int 0, long 10551510, long * 0x0012fc3c) line 2993 + 24 bytes nsWindow::WindowProc(HWND__ * 0x00840280, unsigned int 514, unsigned int 0, long 10551510) line 943 + 27 bytes USER32! 77e71820() The function which does the creation of the files is _PR_MD_OPEN() in nsprpub\pr\src\md\windows\w95io.c and it issues the following windows call to create files: file = CreateFile(name, access, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, flags, flag6, NULL); The caller's desired 'access mode' (i.e., 600) is passed into this function but the value is never used. Instead, only the passed-in 'nspr mode' value is used to determine if the 'access' parameter to window's CreateFile() call is GENERIC_READ and/or GENERIC_WRITE. The tag for the nspr is NSPRPUB_CLIENT_BRANCH.
adding dependency.
Blocks: 58580
Status: NEW → ASSIGNED
PR_Open ignores the mode argument on Windows. We can't change that because that would break backward compatibility with a buggy behavior that some NSPR clients may happen to depend on. We do however provide a new function, PR_OpenFile, that is supposed to set the file access mode correctly if the underlying file system such as NTFS supports access control.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.