hplip/hplip-mkstemp.patch

47 lines
1.5 KiB
Diff

diff -up hplip-3.13.5/common/utils.c.mkstemp hplip-3.13.5/common/utils.c
--- hplip-3.13.5/common/utils.c.mkstemp 2013-05-29 15:21:17.210289396 +0100
+++ hplip-3.13.5/common/utils.c 2013-05-29 15:24:57.214498909 +0100
@@ -222,8 +222,6 @@ void unload_library(void *pLibHandler)
int createTempFile(char* szFileName, FILE** pFilePtr)
{
char* pFilePos = NULL;
- char szFolderName[64]={0,};
- struct stat st;
int iFD;
if (szFileName == NULL || szFileName[0] == '\0' || pFilePtr == NULL)
@@ -235,28 +233,11 @@ int createTempFile(char* szFileName, FIL
if (strstr(szFileName,"XXXXXX") == NULL)
strcat(szFileName,"_XXXXXX");
- pFilePos = strrchr(szFileName, '/');
- if (pFilePos)
- {
- strncpy(szFolderName, szFileName, (pFilePos - szFileName));
- if(stat(szFolderName,&st) == 0)
- {
- if(st.st_mode & S_IFDIR != 0)
- {
- iFD = mkstemp(szFileName);
- *pFilePtr = fdopen(iFD,"w+");
- }
- else
- BUG("Insufficient directory [%s] permissions\n",szFolderName);
- }
- else
- BUG("Failed to check directory [%s] errno[%d]\n",szFolderName, errno);
- }
+ iFD = mkstemp(szFileName);
+ if (iFD == -1)
+ BUG("Failed to create tmpfile [%s]: %s\n", szFileName, strerror (errno));
else
- {
- iFD = mkstemp(szFileName);
*pFilePtr = fdopen(iFD,"w+");
- }
return iFD;
-}
\ No newline at end of file
+}