X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Frand%2Frandfile.c;h=8318df1c408f9c19fe8b933891f886e044743c93;hb=17e3dd1c62e9aadcd908c55e650f70379d2d19e2;hp=1cea7696f963e31f9dd6a3e9ab0b896bc433c9eb;hpb=6b691a5c85ddc4e407e32781841fee5c029506cd;p=oweals%2Fopenssl.git diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 1cea7696f9..8318df1c40 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -56,14 +56,21 @@ * [including the GNU Public Licence.] */ +#include #include #include #include #include #include #include -#include "e_os.h" -#include "rand.h" + +#ifndef FLAT_INC +# include "../e_os.h" +#else +# include "e_os.h" +#endif + +#include #undef BUFSIZE #define BUFSIZE 1024 @@ -113,7 +120,17 @@ int RAND_write_file(const char *file) FILE *out; int n; - out=fopen(file,"wb"); + /* Under VMS, fopen(file, "wb") will craete a new version of the + same file. This is not good, so let's try updating an existing + one, and create file only if it doesn't already exist. This + should be completely harmless on system that have no file + versions. -- Richard Levitte */ + out=fopen(file,"rb+"); + if (out == NULL && errno == ENOENT) + { + errno = 0; + out=fopen(file,"wb"); + } if (out == NULL) goto err; chmod(file,0600); n=RAND_DATA; @@ -156,7 +173,9 @@ char *RAND_file_name(char *buf, int size) if (((int)(strlen(s)+strlen(RFILE)+2)) > size) return(RFILE); strcpy(buf,s); +#ifndef VMS strcat(buf,"/"); +#endif strcat(buf,RFILE); ret=buf; }