fix stdio mode
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 26 Nov 2010 06:02:05 +0000 (06:02 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 26 Nov 2010 06:02:05 +0000 (06:02 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10638 d7cf8633-e32d-0410-b094-e92efae38249

crypto-keygen-standalone.c

index be60446..66a8447 100644 (file)
@@ -98,7 +98,7 @@ void file2buf(const char *fn, char **data, size_t *datasize)
        *datasize = 0;
        size_t n = 0, dn = 0;
        if(!strncmp(fn, "/dev/fd/", 8))
-               f = fdopen(atoi(fn + 8), "wb");
+               f = fdopen(atoi(fn + 8), "rb");
        else
                f = fopen(fn, "rb");
        if(!f)
@@ -111,6 +111,7 @@ void file2buf(const char *fn, char **data, size_t *datasize)
                if(!*data)
                {
                        *datasize = 0;
+                       fclose(f);
                        return;
                }
                dn = fread(*data + n, 1, *datasize - n, f);