[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-announce
Subject: Re: Security patch for KDE libraries
From: Matthias Hoelzer-Kluepfel <mhk () caldera ! de>
Date: 1999-03-03 9:17:42
[Download RAW message or body]
Hi,
due to some internal communication problems, that patch I
announced yesterday did not yet arrive on ftp.kde.org. As the
actual patch is much shorter than the annoncement, I have
attached it to this mail.
Sorry for this inconvenience.
Bye,
Matthias.
================================================================
Matthias Hoelzer-Kluepfel hoelzer@kde.org
mhk@caldera.de
----------------------------------------------------------------
["kdelibs-1.1-connect.patch" (APPLICATION/X-PATCH)]
--- kdelibs-1.1/mediatool/connect.c.connect Wed Dec 9 11:51:17 1998
+++ kdelibs-1.1/mediatool/connect.c Tue Feb 23 11:01:42 1999
@@ -24,6 +24,8 @@
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/types.h>
+#include <fcntl.h>
+#include <errno.h>
#include "mediatool.h"
#include "chunk.h"
@@ -171,9 +173,7 @@
void MdConnectNew(MediaCon *mcon)
{
char *tmpadr, *StartAdr;
- struct stat finfo;
int ret, ref, newRefnum;
- FILE *fid;
MdCh_IHDR HeadChunk;
MdCh_KEYS KeysChunk;
MdCh_STAT StatChunk;
@@ -194,15 +194,26 @@
strcpy(pathkey,mckey);
sprintf(pathkey+strlen(pathkey), "%i", newRefnum);
- ret = stat(pathkey, &finfo);
- if ( ret < 0 ) {
- fid = fopen(pathkey, "w");
- if ( fid==NULL ) {
+ /* Try to open temp file safely. We can't just do a
+ * if (stat() < 0)
+ * fopen(path, "w")
+ * because that is still raceable by flipping symlinks.
+ *
+ * ftok() is a stupid kludge anyway, and is likely to clutter
+ * your disk with stupid temp files. A better approach may be
+ * to do a SHM_INFO (get max shmid), loop over all shmids and
+ * do a SHM_STAT to see whether we can attach to that segment,
+ * if yes, attach to it and check for MDTO signature and
+ * pathkey in HeadChunk.ipcfname. --okir
+ */
+ ret = open(pathkey, O_WRONLY|O_CREAT|O_EXCL, 0600);
+ if (ret >= 0)
+ close(ret);
+ else if (errno != EEXIST)
+ {
LogError("Could not create a shared talk key file.");
return;
}
- fclose(fid);
- }
/* Now it is guaranteed, a file exists. Get the adress. */
/* Get the talk key for that file. */
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic