MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / log_open_default

Function log_open_default

src/log.c:103–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101 @*/
102#if defined(__CYGWIN__) || defined(__MINGW32__)
103int log_open_default(const char*default_filename, const int mode, int *errsv)
104{
105 char*filename;
106 char *path;
107 int result;
108 if(log_handle != NULL)
109 return 1;
110 path = getenv("USERPROFILE");
111 if (path == NULL)
112 path = getenv("HOMEPATH");
113 if(path == NULL)
114 return log_open(default_filename, mode, errsv);
115 /* Check to avoid buffer overflow may not be 100% bullet proof */
116 if(strlen(path)+strlen(default_filename)+2 > 4096)
117 return log_open(default_filename, mode, errsv);
118 filename=(char*)MALLOC(4096);
119#ifdef __CYGWIN__
120 cygwin_conv_path(CCP_WIN_A_TO_POSIX, path, filename, 4096);
121#else
122 strcpy(filename, path);
123#endif
124 strcat(filename, "/");
125 strcat(filename, default_filename);
126 result=log_open(filename, mode, errsv);
127 free(filename);
128 return result;
129}
130#else
131int log_open_default(const char*default_filename, const int mode, int *errsv)
132{

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 2

log_openFunction · 0.85
MALLOCFunction · 0.85

Tested by 1

mainFunction · 0.68