idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
3,000
|
_dbus_delete_directory (const DBusString *filename,
DBusError *error)
{
const char *filename_c;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
filename_c = _dbus_string_get_const_data (filename);
if (RemoveDirectoryA (filename_c) == 0)
{
char *emsg = _dbus_win_error_string (GetLastError ());
dbus_set_error (error, _dbus_win_error_from_last_error (),
"Failed to remove directory %s: %s",
filename_c, emsg);
_dbus_win_free_error_string (emsg);
return FALSE;
}
return TRUE;
}
|
DoS
| 0
|
_dbus_delete_directory (const DBusString *filename,
DBusError *error)
{
const char *filename_c;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
filename_c = _dbus_string_get_const_data (filename);
if (RemoveDirectoryA (filename_c) == 0)
{
char *emsg = _dbus_win_error_string (GetLastError ());
dbus_set_error (error, _dbus_win_error_from_last_error (),
"Failed to remove directory %s: %s",
filename_c, emsg);
_dbus_win_free_error_string (emsg);
return FALSE;
}
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,001
|
_dbus_delete_file (const DBusString *filename,
DBusError *error)
{
const char *filename_c;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
filename_c = _dbus_string_get_const_data (filename);
if (DeleteFileA (filename_c) == 0)
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Failed to delete file %s: %s\n",
filename_c, _dbus_strerror_from_errno ());
return FALSE;
}
else
return TRUE;
}
|
DoS
| 0
|
_dbus_delete_file (const DBusString *filename,
DBusError *error)
{
const char *filename_c;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
filename_c = _dbus_string_get_const_data (filename);
if (DeleteFileA (filename_c) == 0)
{
dbus_set_error (error, DBUS_ERROR_FAILED,
"Failed to delete file %s: %s\n",
filename_c, _dbus_strerror_from_errno ());
return FALSE;
}
else
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,002
|
_dbus_disable_sigpipe (void)
{
}
|
DoS
| 0
|
_dbus_disable_sigpipe (void)
{
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,003
|
_dbus_fd_set_close_on_exec (intptr_t handle)
{
if ( !SetHandleInformation( (HANDLE) handle,
HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE,
0 /*disable both flags*/ ) )
{
_dbus_win_warn_win_error ("Disabling socket handle inheritance failed:", GetLastError());
}
}
|
DoS
| 0
|
_dbus_fd_set_close_on_exec (intptr_t handle)
{
if ( !SetHandleInformation( (HANDLE) handle,
HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE,
0 /*disable both flags*/ ) )
{
_dbus_win_warn_win_error ("Disabling socket handle inheritance failed:", GetLastError());
}
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,004
|
_dbus_full_duplex_pipe (int *fd1,
int *fd2,
dbus_bool_t blocking,
DBusError *error)
{
SOCKET temp, socket1 = -1, socket2 = -1;
struct sockaddr_in saddr;
int len;
u_long arg;
_dbus_win_startup_winsock ();
temp = socket (AF_INET, SOCK_STREAM, 0);
if (temp == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
_DBUS_ZERO (saddr);
saddr.sin_family = AF_INET;
saddr.sin_port = 0;
saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
if (bind (temp, (struct sockaddr *)&saddr, sizeof (saddr)) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
if (listen (temp, 1) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
len = sizeof (saddr);
if (getsockname (temp, (struct sockaddr *)&saddr, &len) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
socket1 = socket (AF_INET, SOCK_STREAM, 0);
if (socket1 == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
if (connect (socket1, (struct sockaddr *)&saddr, len) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out1;
}
socket2 = accept (temp, (struct sockaddr *) &saddr, &len);
if (socket2 == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
goto out1;
}
if (!blocking)
{
arg = 1;
if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out2;
}
arg = 1;
if (ioctlsocket (socket2, FIONBIO, &arg) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out2;
}
}
*fd1 = socket1;
*fd2 = socket2;
_dbus_verbose ("full-duplex pipe %d:%d <-> %d:%d\n",
*fd1, socket1, *fd2, socket2);
closesocket (temp);
return TRUE;
out2:
closesocket (socket2);
out1:
closesocket (socket1);
out0:
closesocket (temp);
dbus_set_error (error, _dbus_error_from_errno (errno),
"Could not setup socket pair: %s",
_dbus_strerror_from_errno ());
return FALSE;
}
|
DoS
| 0
|
_dbus_full_duplex_pipe (int *fd1,
int *fd2,
dbus_bool_t blocking,
DBusError *error)
{
SOCKET temp, socket1 = -1, socket2 = -1;
struct sockaddr_in saddr;
int len;
u_long arg;
_dbus_win_startup_winsock ();
temp = socket (AF_INET, SOCK_STREAM, 0);
if (temp == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
_DBUS_ZERO (saddr);
saddr.sin_family = AF_INET;
saddr.sin_port = 0;
saddr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
if (bind (temp, (struct sockaddr *)&saddr, sizeof (saddr)) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
if (listen (temp, 1) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
len = sizeof (saddr);
if (getsockname (temp, (struct sockaddr *)&saddr, &len) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
socket1 = socket (AF_INET, SOCK_STREAM, 0);
if (socket1 == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
goto out0;
}
if (connect (socket1, (struct sockaddr *)&saddr, len) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out1;
}
socket2 = accept (temp, (struct sockaddr *) &saddr, &len);
if (socket2 == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
goto out1;
}
if (!blocking)
{
arg = 1;
if (ioctlsocket (socket1, FIONBIO, &arg) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out2;
}
arg = 1;
if (ioctlsocket (socket2, FIONBIO, &arg) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
goto out2;
}
}
*fd1 = socket1;
*fd2 = socket2;
_dbus_verbose ("full-duplex pipe %d:%d <-> %d:%d\n",
*fd1, socket1, *fd2, socket2);
closesocket (temp);
return TRUE;
out2:
closesocket (socket2);
out1:
closesocket (socket1);
out0:
closesocket (temp);
dbus_set_error (error, _dbus_error_from_errno (errno),
"Could not setup socket pair: %s",
_dbus_strerror_from_errno ());
return FALSE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,005
|
_dbus_generate_random_bytes (DBusString *str,
int n_bytes)
{
int old_len;
char *p;
HCRYPTPROV hprov;
old_len = _dbus_string_get_length (str);
if (!_dbus_string_lengthen (str, n_bytes))
return FALSE;
p = _dbus_string_get_data_len (str, old_len, n_bytes);
if (!CryptAcquireContext (&hprov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
return FALSE;
if (!CryptGenRandom (hprov, n_bytes, p))
{
CryptReleaseContext (hprov, 0);
return FALSE;
}
CryptReleaseContext (hprov, 0);
return TRUE;
}
|
DoS
| 0
|
_dbus_generate_random_bytes (DBusString *str,
int n_bytes)
{
int old_len;
char *p;
HCRYPTPROV hprov;
old_len = _dbus_string_get_length (str);
if (!_dbus_string_lengthen (str, n_bytes))
return FALSE;
p = _dbus_string_get_data_len (str, old_len, n_bytes);
if (!CryptAcquireContext (&hprov, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
return FALSE;
if (!CryptGenRandom (hprov, n_bytes, p))
{
CryptReleaseContext (hprov, 0);
return FALSE;
}
CryptReleaseContext (hprov, 0);
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,006
|
_dbus_get_address_string (DBusString *out, const char *basestring, const char *scope)
{
_dbus_string_init(out);
_dbus_string_append(out,basestring);
if (!scope)
{
return TRUE;
}
else if (strcmp(scope,"*install-path") == 0
|| strcmp(scope,"install-path") == 0)
{
DBusString temp;
if (!_dbus_get_install_root_as_hash(&temp))
{
_dbus_string_free(out);
return FALSE;
}
_dbus_string_append(out,"-");
_dbus_string_append(out,_dbus_string_get_const_data(&temp));
_dbus_string_free(&temp);
}
else if (strcmp(scope,"*user") == 0)
{
_dbus_string_append(out,"-");
if (!_dbus_append_user_from_current_process(out))
{
_dbus_string_free(out);
return FALSE;
}
}
else if (strlen(scope) > 0)
{
_dbus_string_append(out,"-");
_dbus_string_append(out,scope);
return TRUE;
}
return TRUE;
}
|
DoS
| 0
|
_dbus_get_address_string (DBusString *out, const char *basestring, const char *scope)
{
_dbus_string_init(out);
_dbus_string_append(out,basestring);
if (!scope)
{
return TRUE;
}
else if (strcmp(scope,"*install-path") == 0
|| strcmp(scope,"install-path") == 0)
{
DBusString temp;
if (!_dbus_get_install_root_as_hash(&temp))
{
_dbus_string_free(out);
return FALSE;
}
_dbus_string_append(out,"-");
_dbus_string_append(out,_dbus_string_get_const_data(&temp));
_dbus_string_free(&temp);
}
else if (strcmp(scope,"*user") == 0)
{
_dbus_string_append(out,"-");
if (!_dbus_append_user_from_current_process(out))
{
_dbus_string_free(out);
return FALSE;
}
}
else if (strlen(scope) > 0)
{
_dbus_string_append(out,"-");
_dbus_string_append(out,scope);
return TRUE;
}
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,007
|
_dbus_get_autolaunch_address (const char *scope, DBusString *address,
DBusError *error)
{
HANDLE mutex;
STARTUPINFOA si;
PROCESS_INFORMATION pi;
dbus_bool_t retval = FALSE;
LPSTR lpFile;
char dbus_exe_path[MAX_PATH];
char dbus_args[MAX_PATH * 2];
const char * daemon_name = DBUS_DAEMON_NAME ".exe";
DBusString shm_name;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
if (!_dbus_get_shm_name(&shm_name,scope))
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not determine shm name");
return FALSE;
}
mutex = _dbus_global_lock ( cDBusAutolaunchMutex );
if (_dbus_daemon_already_runs(address,&shm_name,scope))
{
_dbus_verbose( "found running dbus daemon at %s\n",
_dbus_string_get_const_data (&shm_name) );
retval = TRUE;
goto out;
}
if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
{
HMODULE hmod;
char dbus_module_path[MAX_PATH];
DWORD rc;
_dbus_verbose( "did not found dbus daemon executable on default search path, "
"trying path where dbus shared library is located");
hmod = _dbus_win_get_dll_hmodule();
rc = GetModuleFileNameA(hmod, dbus_module_path, sizeof(dbus_module_path));
if (rc <= 0)
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not retrieve dbus shared library file name");
retval = FALSE;
goto out;
}
else
{
char *ext_idx = strrchr(dbus_module_path, '\\');
if (ext_idx)
*ext_idx = '\0';
if (!SearchPathA(dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not find dbus-daemon executable");
retval = FALSE;
printf ("please add the path to %s to your PATH environment variable\n", daemon_name);
printf ("or start the daemon manually\n\n");
goto out;
}
_dbus_verbose( "found dbus daemon executable at %s",dbus_module_path);
}
}
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
_snprintf(dbus_args, sizeof(dbus_args) - 1, "\"%s\" %s", dbus_exe_path, " --session");
if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
{
CloseHandle (pi.hThread);
CloseHandle (pi.hProcess);
retval = _dbus_get_autolaunch_shm( address, &shm_name );
if (retval == FALSE)
dbus_set_error_const (error, DBUS_ERROR_FAILED, "Failed to get autolaunch address from launched dbus-daemon");
}
else
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "Failed to launch dbus-daemon");
retval = FALSE;
}
out:
if (retval)
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
else
_DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_global_unlock (mutex);
return retval;
}
|
DoS
| 0
|
_dbus_get_autolaunch_address (const char *scope, DBusString *address,
DBusError *error)
{
HANDLE mutex;
STARTUPINFOA si;
PROCESS_INFORMATION pi;
dbus_bool_t retval = FALSE;
LPSTR lpFile;
char dbus_exe_path[MAX_PATH];
char dbus_args[MAX_PATH * 2];
const char * daemon_name = DBUS_DAEMON_NAME ".exe";
DBusString shm_name;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
if (!_dbus_get_shm_name(&shm_name,scope))
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not determine shm name");
return FALSE;
}
mutex = _dbus_global_lock ( cDBusAutolaunchMutex );
if (_dbus_daemon_already_runs(address,&shm_name,scope))
{
_dbus_verbose( "found running dbus daemon at %s\n",
_dbus_string_get_const_data (&shm_name) );
retval = TRUE;
goto out;
}
if (!SearchPathA(NULL, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
{
HMODULE hmod;
char dbus_module_path[MAX_PATH];
DWORD rc;
_dbus_verbose( "did not found dbus daemon executable on default search path, "
"trying path where dbus shared library is located");
hmod = _dbus_win_get_dll_hmodule();
rc = GetModuleFileNameA(hmod, dbus_module_path, sizeof(dbus_module_path));
if (rc <= 0)
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not retrieve dbus shared library file name");
retval = FALSE;
goto out;
}
else
{
char *ext_idx = strrchr(dbus_module_path, '\\');
if (ext_idx)
*ext_idx = '\0';
if (!SearchPathA(dbus_module_path, daemon_name, NULL, sizeof(dbus_exe_path), dbus_exe_path, &lpFile))
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not find dbus-daemon executable");
retval = FALSE;
printf ("please add the path to %s to your PATH environment variable\n", daemon_name);
printf ("or start the daemon manually\n\n");
goto out;
}
_dbus_verbose( "found dbus daemon executable at %s",dbus_module_path);
}
}
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
_snprintf(dbus_args, sizeof(dbus_args) - 1, "\"%s\" %s", dbus_exe_path, " --session");
if(CreateProcessA(dbus_exe_path, dbus_args, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
{
CloseHandle (pi.hThread);
CloseHandle (pi.hProcess);
retval = _dbus_get_autolaunch_shm( address, &shm_name );
if (retval == FALSE)
dbus_set_error_const (error, DBUS_ERROR_FAILED, "Failed to get autolaunch address from launched dbus-daemon");
}
else
{
dbus_set_error_const (error, DBUS_ERROR_FAILED, "Failed to launch dbus-daemon");
retval = FALSE;
}
out:
if (retval)
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
else
_DBUS_ASSERT_ERROR_IS_SET (error);
_dbus_global_unlock (mutex);
return retval;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,008
|
_dbus_get_autolaunch_shm (DBusString *address, DBusString *shm_name)
{
HANDLE sharedMem;
char *shared_addr;
int i;
for(i=0;i<20;++i) {
sharedMem = OpenFileMappingA( FILE_MAP_READ, FALSE, _dbus_string_get_const_data(shm_name));
if( sharedMem == 0 )
Sleep( 100 );
if ( sharedMem != 0)
break;
}
if( sharedMem == 0 )
return FALSE;
shared_addr = MapViewOfFile( sharedMem, FILE_MAP_READ, 0, 0, 0 );
if( !shared_addr )
return FALSE;
_dbus_string_init( address );
_dbus_string_append( address, shared_addr );
UnmapViewOfFile( shared_addr );
CloseHandle( sharedMem );
return TRUE;
}
|
DoS
| 0
|
_dbus_get_autolaunch_shm (DBusString *address, DBusString *shm_name)
{
HANDLE sharedMem;
char *shared_addr;
int i;
for(i=0;i<20;++i) {
sharedMem = OpenFileMappingA( FILE_MAP_READ, FALSE, _dbus_string_get_const_data(shm_name));
if( sharedMem == 0 )
Sleep( 100 );
if ( sharedMem != 0)
break;
}
if( sharedMem == 0 )
return FALSE;
shared_addr = MapViewOfFile( sharedMem, FILE_MAP_READ, 0, 0, 0 );
if( !shared_addr )
return FALSE;
_dbus_string_init( address );
_dbus_string_append( address, shared_addr );
UnmapViewOfFile( shared_addr );
CloseHandle( sharedMem );
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,009
|
_dbus_get_config_file_name(DBusString *config_file, char *s)
{
char path[MAX_PATH*2];
int path_size = sizeof(path);
if (!_dbus_get_install_root(path,path_size))
return FALSE;
if(strlen(s) + 4 + strlen(path) > sizeof(path)-2)
return FALSE;
strcat(path,"etc\\");
strcat(path,s);
if (_dbus_file_exists(path))
{
if (!_dbus_string_append (config_file, path))
return FALSE;
}
else
{
if (!_dbus_get_install_root(path,path_size))
return FALSE;
if(strlen(s) + 11 + strlen(path) > sizeof(path)-2)
return FALSE;
strcat(path,"etc\\dbus-1\\");
strcat(path,s);
if (_dbus_file_exists(path))
{
if (!_dbus_string_append (config_file, path))
return FALSE;
}
else
{
if (!_dbus_get_install_root(path,path_size))
return FALSE;
if(strlen(s) + 4 + strlen(path) > sizeof(path)-2)
return FALSE;
strcat(path,"bus\\");
strcat(path,s);
if (_dbus_file_exists(path))
{
if (!_dbus_string_append (config_file, path))
return FALSE;
}
}
}
return TRUE;
}
|
DoS
| 0
|
_dbus_get_config_file_name(DBusString *config_file, char *s)
{
char path[MAX_PATH*2];
int path_size = sizeof(path);
if (!_dbus_get_install_root(path,path_size))
return FALSE;
if(strlen(s) + 4 + strlen(path) > sizeof(path)-2)
return FALSE;
strcat(path,"etc\\");
strcat(path,s);
if (_dbus_file_exists(path))
{
if (!_dbus_string_append (config_file, path))
return FALSE;
}
else
{
if (!_dbus_get_install_root(path,path_size))
return FALSE;
if(strlen(s) + 11 + strlen(path) > sizeof(path)-2)
return FALSE;
strcat(path,"etc\\dbus-1\\");
strcat(path,s);
if (_dbus_file_exists(path))
{
if (!_dbus_string_append (config_file, path))
return FALSE;
}
else
{
if (!_dbus_get_install_root(path,path_size))
return FALSE;
if(strlen(s) + 4 + strlen(path) > sizeof(path)-2)
return FALSE;
strcat(path,"bus\\");
strcat(path,s);
if (_dbus_file_exists(path))
{
if (!_dbus_string_append (config_file, path))
return FALSE;
}
}
}
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,010
|
_dbus_get_install_root(char *prefix, int len)
{
DWORD pathLength;
char *lastSlash;
SetLastError( 0 );
pathLength = GetModuleFileNameA(_dbus_win_get_dll_hmodule(), prefix, len);
if ( pathLength == 0 || GetLastError() != 0 ) {
*prefix = '\0';
return FALSE;
}
lastSlash = _mbsrchr(prefix, '\\');
if (lastSlash == NULL) {
*prefix = '\0';
return FALSE;
}
lastSlash[1] = 0;
if (lastSlash - prefix >= 4 && strnicmp(lastSlash - 4, "\\bin", 4) == 0)
lastSlash[-3] = 0;
else if (lastSlash - prefix >= 10 && strnicmp(lastSlash - 10, "\\bin\\debug", 10) == 0)
lastSlash[-9] = 0;
else if (lastSlash - prefix >= 12 && strnicmp(lastSlash - 12, "\\bin\\release", 12) == 0)
lastSlash[-11] = 0;
return TRUE;
}
|
DoS
| 0
|
_dbus_get_install_root(char *prefix, int len)
{
DWORD pathLength;
char *lastSlash;
SetLastError( 0 );
pathLength = GetModuleFileNameA(_dbus_win_get_dll_hmodule(), prefix, len);
if ( pathLength == 0 || GetLastError() != 0 ) {
*prefix = '\0';
return FALSE;
}
lastSlash = _mbsrchr(prefix, '\\');
if (lastSlash == NULL) {
*prefix = '\0';
return FALSE;
}
lastSlash[1] = 0;
if (lastSlash - prefix >= 4 && strnicmp(lastSlash - 4, "\\bin", 4) == 0)
lastSlash[-3] = 0;
else if (lastSlash - prefix >= 10 && strnicmp(lastSlash - 10, "\\bin\\debug", 10) == 0)
lastSlash[-9] = 0;
else if (lastSlash - prefix >= 12 && strnicmp(lastSlash - 12, "\\bin\\release", 12) == 0)
lastSlash[-11] = 0;
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,011
|
_dbus_get_install_root_as_hash(DBusString *out)
{
DBusString install_path;
char path[MAX_PATH*2];
int path_size = sizeof(path);
if (!_dbus_get_install_root(path,path_size))
return FALSE;
_dbus_string_init(&install_path);
_dbus_string_append(&install_path,path);
_dbus_string_init(out);
_dbus_string_tolower_ascii(&install_path,0,_dbus_string_get_length(&install_path));
if (!_dbus_sha_compute (&install_path, out))
return FALSE;
return TRUE;
}
|
DoS
| 0
|
_dbus_get_install_root_as_hash(DBusString *out)
{
DBusString install_path;
char path[MAX_PATH*2];
int path_size = sizeof(path);
if (!_dbus_get_install_root(path,path_size))
return FALSE;
_dbus_string_init(&install_path);
_dbus_string_append(&install_path,path);
_dbus_string_init(out);
_dbus_string_tolower_ascii(&install_path,0,_dbus_string_get_length(&install_path));
if (!_dbus_sha_compute (&install_path, out))
return FALSE;
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,012
|
_dbus_get_is_errno_eagain_or_ewouldblock (void)
{
return errno == WSAEWOULDBLOCK;
}
|
DoS
| 0
|
_dbus_get_is_errno_eagain_or_ewouldblock (void)
{
return errno == WSAEWOULDBLOCK;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,013
|
_dbus_get_monotonic_time (long *tv_sec,
long *tv_usec)
{
/* no implementation yet, fall back to wall-clock time */
_dbus_get_real_time (tv_sec, tv_usec);
}
|
DoS
| 0
|
_dbus_get_monotonic_time (long *tv_sec,
long *tv_usec)
{
/* no implementation yet, fall back to wall-clock time */
_dbus_get_real_time (tv_sec, tv_usec);
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,014
|
_dbus_get_mutex_name (DBusString *out,const char *scope)
{
return _dbus_get_address_string (out,cDBusDaemonMutex,scope);
}
|
DoS
| 0
|
_dbus_get_mutex_name (DBusString *out,const char *scope)
{
return _dbus_get_address_string (out,cDBusDaemonMutex,scope);
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,015
|
_dbus_get_real_time (long *tv_sec,
long *tv_usec)
{
FILETIME ft;
dbus_uint64_t time64;
GetSystemTimeAsFileTime (&ft);
memcpy (&time64, &ft, sizeof (time64));
/* Convert from 100s of nanoseconds since 1601-01-01
* to Unix epoch. Yes, this is Y2038 unsafe.
*/
time64 -= DBUS_INT64_CONSTANT (116444736000000000);
time64 /= 10;
if (tv_sec)
*tv_sec = time64 / 1000000;
if (tv_usec)
*tv_usec = time64 % 1000000;
}
|
DoS
| 0
|
_dbus_get_real_time (long *tv_sec,
long *tv_usec)
{
FILETIME ft;
dbus_uint64_t time64;
GetSystemTimeAsFileTime (&ft);
memcpy (&time64, &ft, sizeof (time64));
/* Convert from 100s of nanoseconds since 1601-01-01
* to Unix epoch. Yes, this is Y2038 unsafe.
*/
time64 -= DBUS_INT64_CONSTANT (116444736000000000);
time64 /= 10;
if (tv_sec)
*tv_sec = time64 / 1000000;
if (tv_usec)
*tv_usec = time64 % 1000000;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,016
|
_dbus_get_shm_name (DBusString *out,const char *scope)
{
return _dbus_get_address_string (out,cDBusDaemonAddressInfo,scope);
}
|
DoS
| 0
|
_dbus_get_shm_name (DBusString *out,const char *scope)
{
return _dbus_get_address_string (out,cDBusDaemonAddressInfo,scope);
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,017
|
_dbus_get_standard_session_servicedirs (DBusList **dirs)
{
const char *common_progs;
DBusString servicedir_path;
if (!_dbus_string_init (&servicedir_path))
return FALSE;
#ifdef DBUS_WINCE
{
/* On Windows CE, we adjust datadir dynamically to installation location. */
const char *data_dir = _dbus_getenv ("DBUS_DATADIR");
if (data_dir != NULL)
{
if (!_dbus_string_append (&servicedir_path, data_dir))
goto oom;
if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
goto oom;
}
}
#else
/*
the code for accessing services requires absolute base pathes
in case DBUS_DATADIR is relative make it absolute
*/
#ifdef DBUS_WIN
{
DBusString p;
_dbus_string_init_const (&p, DBUS_DATADIR);
if (!_dbus_path_is_absolute (&p))
{
char install_root[1000];
if (_dbus_get_install_root (install_root, sizeof(install_root)))
if (!_dbus_string_append (&servicedir_path, install_root))
goto oom;
}
}
#endif
if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR))
goto oom;
if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
goto oom;
#endif
common_progs = _dbus_getenv ("CommonProgramFiles");
if (common_progs != NULL)
{
if (!_dbus_string_append (&servicedir_path, common_progs))
goto oom;
if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
goto oom;
}
if (!_dbus_split_paths_and_append (&servicedir_path,
DBUS_STANDARD_SESSION_SERVICEDIR,
dirs))
goto oom;
_dbus_string_free (&servicedir_path);
return TRUE;
oom:
_dbus_string_free (&servicedir_path);
return FALSE;
}
|
DoS
| 0
|
_dbus_get_standard_session_servicedirs (DBusList **dirs)
{
const char *common_progs;
DBusString servicedir_path;
if (!_dbus_string_init (&servicedir_path))
return FALSE;
#ifdef DBUS_WINCE
{
/* On Windows CE, we adjust datadir dynamically to installation location. */
const char *data_dir = _dbus_getenv ("DBUS_DATADIR");
if (data_dir != NULL)
{
if (!_dbus_string_append (&servicedir_path, data_dir))
goto oom;
if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
goto oom;
}
}
#else
/*
the code for accessing services requires absolute base pathes
in case DBUS_DATADIR is relative make it absolute
*/
#ifdef DBUS_WIN
{
DBusString p;
_dbus_string_init_const (&p, DBUS_DATADIR);
if (!_dbus_path_is_absolute (&p))
{
char install_root[1000];
if (_dbus_get_install_root (install_root, sizeof(install_root)))
if (!_dbus_string_append (&servicedir_path, install_root))
goto oom;
}
}
#endif
if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR))
goto oom;
if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
goto oom;
#endif
common_progs = _dbus_getenv ("CommonProgramFiles");
if (common_progs != NULL)
{
if (!_dbus_string_append (&servicedir_path, common_progs))
goto oom;
if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR))
goto oom;
}
if (!_dbus_split_paths_and_append (&servicedir_path,
DBUS_STANDARD_SESSION_SERVICEDIR,
dirs))
goto oom;
_dbus_string_free (&servicedir_path);
return TRUE;
oom:
_dbus_string_free (&servicedir_path);
return FALSE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,018
|
_dbus_get_standard_system_servicedirs (DBusList **dirs)
{
*dirs = NULL;
return TRUE;
}
|
DoS
| 0
|
_dbus_get_standard_system_servicedirs (DBusList **dirs)
{
*dirs = NULL;
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,019
|
_dbus_getpid (void)
{
return GetCurrentProcessId ();
}
|
DoS
| 0
|
_dbus_getpid (void)
{
return GetCurrentProcessId ();
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,020
|
HANDLE _dbus_global_lock (const char *mutexname)
{
HANDLE mutex;
DWORD gotMutex;
mutex = CreateMutexA( NULL, FALSE, mutexname );
if( !mutex )
{
return FALSE;
}
gotMutex = WaitForSingleObject( mutex, INFINITE );
switch( gotMutex )
{
case WAIT_ABANDONED:
ReleaseMutex (mutex);
CloseHandle (mutex);
return 0;
case WAIT_FAILED:
case WAIT_TIMEOUT:
return 0;
}
return mutex;
}
|
DoS
| 0
|
HANDLE _dbus_global_lock (const char *mutexname)
{
HANDLE mutex;
DWORD gotMutex;
mutex = CreateMutexA( NULL, FALSE, mutexname );
if( !mutex )
{
return FALSE;
}
gotMutex = WaitForSingleObject( mutex, INFINITE );
switch( gotMutex )
{
case WAIT_ABANDONED:
ReleaseMutex (mutex);
CloseHandle (mutex);
return 0;
case WAIT_FAILED:
case WAIT_TIMEOUT:
return 0;
}
return mutex;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,021
|
void _dbus_global_unlock (HANDLE mutex)
{
ReleaseMutex (mutex);
CloseHandle (mutex);
}
|
DoS
| 0
|
void _dbus_global_unlock (HANDLE mutex)
{
ReleaseMutex (mutex);
CloseHandle (mutex);
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,022
|
_dbus_listen_tcp_socket (const char *host,
const char *port,
const char *family,
DBusString *retport,
int **fds_p,
DBusError *error)
{
int nlisten_fd = 0, *listen_fd = NULL, res, i, port_num = -1;
struct addrinfo hints;
struct addrinfo *ai, *tmp;
typedef union {
struct sockaddr Address;
struct sockaddr_in AddressIn;
struct sockaddr_in6 AddressIn6;
} mysockaddr_gen;
*fds_p = NULL;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_win_startup_winsock ();
_DBUS_ZERO (hints);
if (!family)
hints.ai_family = AF_UNSPEC;
else if (!strcmp(family, "ipv4"))
hints.ai_family = AF_INET;
else if (!strcmp(family, "ipv6"))
hints.ai_family = AF_INET6;
else
{
dbus_set_error (error,
DBUS_ERROR_INVALID_ARGS,
"Unknown address family %s", family);
return -1;
}
hints.ai_protocol = IPPROTO_TCP;
hints.ai_socktype = SOCK_STREAM;
#ifdef AI_ADDRCONFIG
hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
#else
hints.ai_flags = AI_PASSIVE;
#endif
redo_lookup_with_port:
if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai)
{
dbus_set_error (error,
_dbus_error_from_errno (res),
"Failed to lookup host/port: \"%s:%s\": %s (%d)",
host ? host : "*", port, _dbus_strerror(res), res);
return -1;
}
tmp = ai;
while (tmp)
{
int fd = -1, *newlisten_fd;
if ((fd = socket (tmp->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error,
_dbus_error_from_errno (errno),
"Failed to open socket: %s",
_dbus_strerror_from_errno ());
goto failed;
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
if (bind (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to bind socket \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno ());
closesocket (fd);
goto failed;
}
if (listen (fd, 30 /* backlog */) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to listen on socket \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno ());
closesocket (fd);
goto failed;
}
newlisten_fd = dbus_realloc(listen_fd, sizeof(int)*(nlisten_fd+1));
if (!newlisten_fd)
{
closesocket (fd);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
"Failed to allocate file handle array");
goto failed;
}
listen_fd = newlisten_fd;
listen_fd[nlisten_fd] = fd;
nlisten_fd++;
if (!_dbus_string_get_length(retport))
{
/* If the user didn't specify a port, or used 0, then
the kernel chooses a port. After the first address
is bound to, we need to force all remaining addresses
to use the same port */
if (!port || !strcmp(port, "0"))
{
mysockaddr_gen addr;
socklen_t addrlen = sizeof(addr);
char portbuf[10];
if (getsockname(fd, &addr.Address, &addrlen) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to resolve port \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno());
goto failed;
}
snprintf( portbuf, sizeof( portbuf ) - 1, "%d", addr.AddressIn.sin_port );
if (!_dbus_string_append(retport, portbuf))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto failed;
}
/* Release current address list & redo lookup */
port = _dbus_string_get_const_data(retport);
freeaddrinfo(ai);
goto redo_lookup_with_port;
}
else
{
if (!_dbus_string_append(retport, port))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto failed;
}
}
}
tmp = tmp->ai_next;
}
freeaddrinfo(ai);
ai = NULL;
if (!nlisten_fd)
{
_dbus_win_set_errno (WSAEADDRINUSE);
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to bind socket \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno ());
return -1;
}
sscanf(_dbus_string_get_const_data(retport), "%d", &port_num);
for (i = 0 ; i < nlisten_fd ; i++)
{
_dbus_fd_set_close_on_exec (listen_fd[i]);
if (!_dbus_set_fd_nonblocking (listen_fd[i], error))
{
goto failed;
}
}
*fds_p = listen_fd;
return nlisten_fd;
failed:
if (ai)
freeaddrinfo(ai);
for (i = 0 ; i < nlisten_fd ; i++)
closesocket (listen_fd[i]);
dbus_free(listen_fd);
return -1;
}
|
DoS
| 0
|
_dbus_listen_tcp_socket (const char *host,
const char *port,
const char *family,
DBusString *retport,
int **fds_p,
DBusError *error)
{
int nlisten_fd = 0, *listen_fd = NULL, res, i, port_num = -1;
struct addrinfo hints;
struct addrinfo *ai, *tmp;
typedef union {
struct sockaddr Address;
struct sockaddr_in AddressIn;
struct sockaddr_in6 AddressIn6;
} mysockaddr_gen;
*fds_p = NULL;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
_dbus_win_startup_winsock ();
_DBUS_ZERO (hints);
if (!family)
hints.ai_family = AF_UNSPEC;
else if (!strcmp(family, "ipv4"))
hints.ai_family = AF_INET;
else if (!strcmp(family, "ipv6"))
hints.ai_family = AF_INET6;
else
{
dbus_set_error (error,
DBUS_ERROR_INVALID_ARGS,
"Unknown address family %s", family);
return -1;
}
hints.ai_protocol = IPPROTO_TCP;
hints.ai_socktype = SOCK_STREAM;
#ifdef AI_ADDRCONFIG
hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
#else
hints.ai_flags = AI_PASSIVE;
#endif
redo_lookup_with_port:
if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai)
{
dbus_set_error (error,
_dbus_error_from_errno (res),
"Failed to lookup host/port: \"%s:%s\": %s (%d)",
host ? host : "*", port, _dbus_strerror(res), res);
return -1;
}
tmp = ai;
while (tmp)
{
int fd = -1, *newlisten_fd;
if ((fd = socket (tmp->ai_family, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error,
_dbus_error_from_errno (errno),
"Failed to open socket: %s",
_dbus_strerror_from_errno ());
goto failed;
}
_DBUS_ASSERT_ERROR_IS_CLEAR(error);
if (bind (fd, (struct sockaddr*) tmp->ai_addr, tmp->ai_addrlen) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to bind socket \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno ());
closesocket (fd);
goto failed;
}
if (listen (fd, 30 /* backlog */) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to listen on socket \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno ());
closesocket (fd);
goto failed;
}
newlisten_fd = dbus_realloc(listen_fd, sizeof(int)*(nlisten_fd+1));
if (!newlisten_fd)
{
closesocket (fd);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
"Failed to allocate file handle array");
goto failed;
}
listen_fd = newlisten_fd;
listen_fd[nlisten_fd] = fd;
nlisten_fd++;
if (!_dbus_string_get_length(retport))
{
/* If the user didn't specify a port, or used 0, then
the kernel chooses a port. After the first address
is bound to, we need to force all remaining addresses
to use the same port */
if (!port || !strcmp(port, "0"))
{
mysockaddr_gen addr;
socklen_t addrlen = sizeof(addr);
char portbuf[10];
if (getsockname(fd, &addr.Address, &addrlen) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to resolve port \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno());
goto failed;
}
snprintf( portbuf, sizeof( portbuf ) - 1, "%d", addr.AddressIn.sin_port );
if (!_dbus_string_append(retport, portbuf))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto failed;
}
/* Release current address list & redo lookup */
port = _dbus_string_get_const_data(retport);
freeaddrinfo(ai);
goto redo_lookup_with_port;
}
else
{
if (!_dbus_string_append(retport, port))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto failed;
}
}
}
tmp = tmp->ai_next;
}
freeaddrinfo(ai);
ai = NULL;
if (!nlisten_fd)
{
_dbus_win_set_errno (WSAEADDRINUSE);
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to bind socket \"%s:%s\": %s",
host ? host : "*", port, _dbus_strerror_from_errno ());
return -1;
}
sscanf(_dbus_string_get_const_data(retport), "%d", &port_num);
for (i = 0 ; i < nlisten_fd ; i++)
{
_dbus_fd_set_close_on_exec (listen_fd[i]);
if (!_dbus_set_fd_nonblocking (listen_fd[i], error))
{
goto failed;
}
}
*fds_p = listen_fd;
return nlisten_fd;
failed:
if (ai)
freeaddrinfo(ai);
for (i = 0 ; i < nlisten_fd ; i++)
closesocket (listen_fd[i]);
dbus_free(listen_fd);
return -1;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,023
|
_dbus_lookup_session_address (dbus_bool_t *supported,
DBusString *address,
DBusError *error)
{
/* Probably fill this in with something based on COM? */
*supported = FALSE;
return TRUE;
}
|
DoS
| 0
|
_dbus_lookup_session_address (dbus_bool_t *supported,
DBusString *address,
DBusError *error)
{
/* Probably fill this in with something based on COM? */
*supported = FALSE;
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,024
|
_dbus_make_file_world_readable(const DBusString *filename,
DBusError *error)
{
return TRUE;
}
|
DoS
| 0
|
_dbus_make_file_world_readable(const DBusString *filename,
DBusError *error)
{
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,025
|
_dbus_path_is_absolute (const DBusString *filename)
{
if (_dbus_string_get_length (filename) > 0)
return _dbus_string_get_byte (filename, 1) == ':'
|| _dbus_string_get_byte (filename, 0) == '\\'
|| _dbus_string_get_byte (filename, 0) == '/';
else
return FALSE;
}
|
DoS
| 0
|
_dbus_path_is_absolute (const DBusString *filename)
{
if (_dbus_string_get_length (filename) > 0)
return _dbus_string_get_byte (filename, 1) == ':'
|| _dbus_string_get_byte (filename, 0) == '\\'
|| _dbus_string_get_byte (filename, 0) == '/';
else
return FALSE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,026
|
dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id,
dbus_bool_t create_if_not_found,
DBusError *error)
{
#ifdef DBUS_WINCE
return TRUE;
#else
HW_PROFILE_INFOA info;
char *lpc = &info.szHwProfileGuid[0];
dbus_uint32_t u;
if(!GetCurrentHwProfileA(&info))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); // FIXME
return FALSE;
}
lpc++;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[4]) << 16) |
(fromAscii(lpc[5]) << 20) |
(fromAscii(lpc[6]) << 24) |
(fromAscii(lpc[7]) << 28));
machine_id->as_uint32s[0] = u;
lpc += 9;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[5]) << 16) |
(fromAscii(lpc[6]) << 20) |
(fromAscii(lpc[7]) << 24) |
(fromAscii(lpc[8]) << 28));
machine_id->as_uint32s[1] = u;
lpc += 10;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[5]) << 16) |
(fromAscii(lpc[6]) << 20) |
(fromAscii(lpc[7]) << 24) |
(fromAscii(lpc[8]) << 28));
machine_id->as_uint32s[2] = u;
lpc += 9;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[4]) << 16) |
(fromAscii(lpc[5]) << 20) |
(fromAscii(lpc[6]) << 24) |
(fromAscii(lpc[7]) << 28));
machine_id->as_uint32s[3] = u;
#endif
return TRUE;
}
|
DoS
| 0
|
dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id,
dbus_bool_t create_if_not_found,
DBusError *error)
{
#ifdef DBUS_WINCE
return TRUE;
#else
HW_PROFILE_INFOA info;
char *lpc = &info.szHwProfileGuid[0];
dbus_uint32_t u;
if(!GetCurrentHwProfileA(&info))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); // FIXME
return FALSE;
}
lpc++;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[4]) << 16) |
(fromAscii(lpc[5]) << 20) |
(fromAscii(lpc[6]) << 24) |
(fromAscii(lpc[7]) << 28));
machine_id->as_uint32s[0] = u;
lpc += 9;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[5]) << 16) |
(fromAscii(lpc[6]) << 20) |
(fromAscii(lpc[7]) << 24) |
(fromAscii(lpc[8]) << 28));
machine_id->as_uint32s[1] = u;
lpc += 10;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[5]) << 16) |
(fromAscii(lpc[6]) << 20) |
(fromAscii(lpc[7]) << 24) |
(fromAscii(lpc[8]) << 28));
machine_id->as_uint32s[2] = u;
lpc += 9;
u = ((fromAscii(lpc[0]) << 0) |
(fromAscii(lpc[1]) << 4) |
(fromAscii(lpc[2]) << 8) |
(fromAscii(lpc[3]) << 12) |
(fromAscii(lpc[4]) << 16) |
(fromAscii(lpc[5]) << 20) |
(fromAscii(lpc[6]) << 24) |
(fromAscii(lpc[7]) << 28));
machine_id->as_uint32s[3] = u;
#endif
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,027
|
_dbus_read_socket (int fd,
DBusString *buffer,
int count)
{
int bytes_read;
int start;
char *data;
_dbus_assert (count >= 0);
start = _dbus_string_get_length (buffer);
if (!_dbus_string_lengthen (buffer, count))
{
_dbus_win_set_errno (ENOMEM);
return -1;
}
data = _dbus_string_get_data_len (buffer, start, count);
again:
_dbus_verbose ("recv: count=%d fd=%d\n", count, fd);
bytes_read = recv (fd, data, count, 0);
if (bytes_read == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO();
_dbus_verbose ("recv: failed: %s (%d)\n", _dbus_strerror (errno), errno);
bytes_read = -1;
}
else
_dbus_verbose ("recv: = %d\n", bytes_read);
if (bytes_read < 0)
{
if (errno == EINTR)
goto again;
else
{
/* put length back (note that this doesn't actually realloc anything) */
_dbus_string_set_length (buffer, start);
return -1;
}
}
else
{
/* put length back (doesn't actually realloc) */
_dbus_string_set_length (buffer, start + bytes_read);
#if 0
if (bytes_read > 0)
_dbus_verbose_bytes_of_string (buffer, start, bytes_read);
#endif
return bytes_read;
}
}
|
DoS
| 0
|
_dbus_read_socket (int fd,
DBusString *buffer,
int count)
{
int bytes_read;
int start;
char *data;
_dbus_assert (count >= 0);
start = _dbus_string_get_length (buffer);
if (!_dbus_string_lengthen (buffer, count))
{
_dbus_win_set_errno (ENOMEM);
return -1;
}
data = _dbus_string_get_data_len (buffer, start, count);
again:
_dbus_verbose ("recv: count=%d fd=%d\n", count, fd);
bytes_read = recv (fd, data, count, 0);
if (bytes_read == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO();
_dbus_verbose ("recv: failed: %s (%d)\n", _dbus_strerror (errno), errno);
bytes_read = -1;
}
else
_dbus_verbose ("recv: = %d\n", bytes_read);
if (bytes_read < 0)
{
if (errno == EINTR)
goto again;
else
{
/* put length back (note that this doesn't actually realloc anything) */
_dbus_string_set_length (buffer, start);
return -1;
}
}
else
{
/* put length back (doesn't actually realloc) */
_dbus_string_set_length (buffer, start + bytes_read);
#if 0
if (bytes_read > 0)
_dbus_verbose_bytes_of_string (buffer, start, bytes_read);
#endif
return bytes_read;
}
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,028
|
_dbus_set_fd_nonblocking (int handle,
DBusError *error)
{
u_long one = 1;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
if (ioctlsocket (handle, FIONBIO, &one) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to set socket %d:%d to nonblocking: %s", handle,
_dbus_strerror_from_errno ());
return FALSE;
}
return TRUE;
}
|
DoS
| 0
|
_dbus_set_fd_nonblocking (int handle,
DBusError *error)
{
u_long one = 1;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
if (ioctlsocket (handle, FIONBIO, &one) == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO ();
dbus_set_error (error, _dbus_error_from_errno (errno),
"Failed to set socket %d:%d to nonblocking: %s", handle,
_dbus_strerror_from_errno ());
return FALSE;
}
return TRUE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,029
|
_dbus_socket_is_invalid (int fd)
{
return fd == INVALID_SOCKET ? TRUE : FALSE;
}
|
DoS
| 0
|
_dbus_socket_is_invalid (int fd)
{
return fd == INVALID_SOCKET ? TRUE : FALSE;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,030
|
_dbus_strerror (int error_number)
{
#ifdef DBUS_WINCE
return "unknown";
#else
const char *msg;
switch (error_number)
{
case WSAEINTR:
return "Interrupted function call";
case WSAEACCES:
return "Permission denied";
case WSAEFAULT:
return "Bad address";
case WSAEINVAL:
return "Invalid argument";
case WSAEMFILE:
return "Too many open files";
case WSAEWOULDBLOCK:
return "Resource temporarily unavailable";
case WSAEINPROGRESS:
return "Operation now in progress";
case WSAEALREADY:
return "Operation already in progress";
case WSAENOTSOCK:
return "Socket operation on nonsocket";
case WSAEDESTADDRREQ:
return "Destination address required";
case WSAEMSGSIZE:
return "Message too long";
case WSAEPROTOTYPE:
return "Protocol wrong type for socket";
case WSAENOPROTOOPT:
return "Bad protocol option";
case WSAEPROTONOSUPPORT:
return "Protocol not supported";
case WSAESOCKTNOSUPPORT:
return "Socket type not supported";
case WSAEOPNOTSUPP:
return "Operation not supported";
case WSAEPFNOSUPPORT:
return "Protocol family not supported";
case WSAEAFNOSUPPORT:
return "Address family not supported by protocol family";
case WSAEADDRINUSE:
return "Address already in use";
case WSAEADDRNOTAVAIL:
return "Cannot assign requested address";
case WSAENETDOWN:
return "Network is down";
case WSAENETUNREACH:
return "Network is unreachable";
case WSAENETRESET:
return "Network dropped connection on reset";
case WSAECONNABORTED:
return "Software caused connection abort";
case WSAECONNRESET:
return "Connection reset by peer";
case WSAENOBUFS:
return "No buffer space available";
case WSAEISCONN:
return "Socket is already connected";
case WSAENOTCONN:
return "Socket is not connected";
case WSAESHUTDOWN:
return "Cannot send after socket shutdown";
case WSAETIMEDOUT:
return "Connection timed out";
case WSAECONNREFUSED:
return "Connection refused";
case WSAEHOSTDOWN:
return "Host is down";
case WSAEHOSTUNREACH:
return "No route to host";
case WSAEPROCLIM:
return "Too many processes";
case WSAEDISCON:
return "Graceful shutdown in progress";
case WSATYPE_NOT_FOUND:
return "Class type not found";
case WSAHOST_NOT_FOUND:
return "Host not found";
case WSATRY_AGAIN:
return "Nonauthoritative host not found";
case WSANO_RECOVERY:
return "This is a nonrecoverable error";
case WSANO_DATA:
return "Valid name, no data record of requested type";
case WSA_INVALID_HANDLE:
return "Specified event object handle is invalid";
case WSA_INVALID_PARAMETER:
return "One or more parameters are invalid";
case WSA_IO_INCOMPLETE:
return "Overlapped I/O event object not in signaled state";
case WSA_IO_PENDING:
return "Overlapped operations will complete later";
case WSA_NOT_ENOUGH_MEMORY:
return "Insufficient memory available";
case WSA_OPERATION_ABORTED:
return "Overlapped operation aborted";
#ifdef WSAINVALIDPROCTABLE
case WSAINVALIDPROCTABLE:
return "Invalid procedure table from service provider";
#endif
#ifdef WSAINVALIDPROVIDER
case WSAINVALIDPROVIDER:
return "Invalid service provider version number";
#endif
#ifdef WSAPROVIDERFAILEDINIT
case WSAPROVIDERFAILEDINIT:
return "Unable to initialize a service provider";
#endif
case WSASYSCALLFAILURE:
return "System call failure";
}
msg = strerror (error_number);
if (msg == NULL)
msg = "unknown";
return msg;
#endif //DBUS_WINCE
}
|
DoS
| 0
|
_dbus_strerror (int error_number)
{
#ifdef DBUS_WINCE
return "unknown";
#else
const char *msg;
switch (error_number)
{
case WSAEINTR:
return "Interrupted function call";
case WSAEACCES:
return "Permission denied";
case WSAEFAULT:
return "Bad address";
case WSAEINVAL:
return "Invalid argument";
case WSAEMFILE:
return "Too many open files";
case WSAEWOULDBLOCK:
return "Resource temporarily unavailable";
case WSAEINPROGRESS:
return "Operation now in progress";
case WSAEALREADY:
return "Operation already in progress";
case WSAENOTSOCK:
return "Socket operation on nonsocket";
case WSAEDESTADDRREQ:
return "Destination address required";
case WSAEMSGSIZE:
return "Message too long";
case WSAEPROTOTYPE:
return "Protocol wrong type for socket";
case WSAENOPROTOOPT:
return "Bad protocol option";
case WSAEPROTONOSUPPORT:
return "Protocol not supported";
case WSAESOCKTNOSUPPORT:
return "Socket type not supported";
case WSAEOPNOTSUPP:
return "Operation not supported";
case WSAEPFNOSUPPORT:
return "Protocol family not supported";
case WSAEAFNOSUPPORT:
return "Address family not supported by protocol family";
case WSAEADDRINUSE:
return "Address already in use";
case WSAEADDRNOTAVAIL:
return "Cannot assign requested address";
case WSAENETDOWN:
return "Network is down";
case WSAENETUNREACH:
return "Network is unreachable";
case WSAENETRESET:
return "Network dropped connection on reset";
case WSAECONNABORTED:
return "Software caused connection abort";
case WSAECONNRESET:
return "Connection reset by peer";
case WSAENOBUFS:
return "No buffer space available";
case WSAEISCONN:
return "Socket is already connected";
case WSAENOTCONN:
return "Socket is not connected";
case WSAESHUTDOWN:
return "Cannot send after socket shutdown";
case WSAETIMEDOUT:
return "Connection timed out";
case WSAECONNREFUSED:
return "Connection refused";
case WSAEHOSTDOWN:
return "Host is down";
case WSAEHOSTUNREACH:
return "No route to host";
case WSAEPROCLIM:
return "Too many processes";
case WSAEDISCON:
return "Graceful shutdown in progress";
case WSATYPE_NOT_FOUND:
return "Class type not found";
case WSAHOST_NOT_FOUND:
return "Host not found";
case WSATRY_AGAIN:
return "Nonauthoritative host not found";
case WSANO_RECOVERY:
return "This is a nonrecoverable error";
case WSANO_DATA:
return "Valid name, no data record of requested type";
case WSA_INVALID_HANDLE:
return "Specified event object handle is invalid";
case WSA_INVALID_PARAMETER:
return "One or more parameters are invalid";
case WSA_IO_INCOMPLETE:
return "Overlapped I/O event object not in signaled state";
case WSA_IO_PENDING:
return "Overlapped operations will complete later";
case WSA_NOT_ENOUGH_MEMORY:
return "Insufficient memory available";
case WSA_OPERATION_ABORTED:
return "Overlapped operation aborted";
#ifdef WSAINVALIDPROCTABLE
case WSAINVALIDPROCTABLE:
return "Invalid procedure table from service provider";
#endif
#ifdef WSAINVALIDPROVIDER
case WSAINVALIDPROVIDER:
return "Invalid service provider version number";
#endif
#ifdef WSAPROVIDERFAILEDINIT
case WSAPROVIDERFAILEDINIT:
return "Unable to initialize a service provider";
#endif
case WSASYSCALLFAILURE:
return "System call failure";
}
msg = strerror (error_number);
if (msg == NULL)
msg = "unknown";
return msg;
#endif //DBUS_WINCE
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,031
|
_dbus_win_error_from_last_error (void)
{
switch (GetLastError())
{
case 0:
return DBUS_ERROR_FAILED;
case ERROR_NO_MORE_FILES:
case ERROR_TOO_MANY_OPEN_FILES:
return DBUS_ERROR_LIMITS_EXCEEDED; /* kernel out of memory */
case ERROR_ACCESS_DENIED:
case ERROR_CANNOT_MAKE:
return DBUS_ERROR_ACCESS_DENIED;
case ERROR_NOT_ENOUGH_MEMORY:
return DBUS_ERROR_NO_MEMORY;
case ERROR_FILE_EXISTS:
return DBUS_ERROR_FILE_EXISTS;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
return DBUS_ERROR_FILE_NOT_FOUND;
}
return DBUS_ERROR_FAILED;
}
|
DoS
| 0
|
_dbus_win_error_from_last_error (void)
{
switch (GetLastError())
{
case 0:
return DBUS_ERROR_FAILED;
case ERROR_NO_MORE_FILES:
case ERROR_TOO_MANY_OPEN_FILES:
return DBUS_ERROR_LIMITS_EXCEEDED; /* kernel out of memory */
case ERROR_ACCESS_DENIED:
case ERROR_CANNOT_MAKE:
return DBUS_ERROR_ACCESS_DENIED;
case ERROR_NOT_ENOUGH_MEMORY:
return DBUS_ERROR_NO_MEMORY;
case ERROR_FILE_EXISTS:
return DBUS_ERROR_FILE_EXISTS;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
return DBUS_ERROR_FILE_NOT_FOUND;
}
return DBUS_ERROR_FAILED;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,032
|
_dbus_win_error_string (int error_number)
{
char *msg;
FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error_number, 0,
(LPSTR) &msg, 0, NULL);
if (msg[strlen (msg) - 1] == '\n')
msg[strlen (msg) - 1] = '\0';
if (msg[strlen (msg) - 1] == '\r')
msg[strlen (msg) - 1] = '\0';
return msg;
}
|
DoS
| 0
|
_dbus_win_error_string (int error_number)
{
char *msg;
FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, error_number, 0,
(LPSTR) &msg, 0, NULL);
if (msg[strlen (msg) - 1] == '\n')
msg[strlen (msg) - 1] = '\0';
if (msg[strlen (msg) - 1] == '\r')
msg[strlen (msg) - 1] = '\0';
return msg;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,033
|
_dbus_windows_get_datadir (void)
{
return _dbus_replace_install_prefix(DBUS_DATADIR);
}
|
DoS
| 0
|
_dbus_windows_get_datadir (void)
{
return _dbus_replace_install_prefix(DBUS_DATADIR);
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,034
|
_dbus_write_socket (int fd,
const DBusString *buffer,
int start,
int len)
{
const char *data;
int bytes_written;
data = _dbus_string_get_const_data_len (buffer, start, len);
again:
_dbus_verbose ("send: len=%d fd=%d\n", len, fd);
bytes_written = send (fd, data, len, 0);
if (bytes_written == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO();
_dbus_verbose ("send: failed: %s\n", _dbus_strerror_from_errno ());
bytes_written = -1;
}
else
_dbus_verbose ("send: = %d\n", bytes_written);
if (bytes_written < 0 && errno == EINTR)
goto again;
#if 0
if (bytes_written > 0)
_dbus_verbose_bytes_of_string (buffer, start, bytes_written);
#endif
return bytes_written;
}
|
DoS
| 0
|
_dbus_write_socket (int fd,
const DBusString *buffer,
int start,
int len)
{
const char *data;
int bytes_written;
data = _dbus_string_get_const_data_len (buffer, start, len);
again:
_dbus_verbose ("send: len=%d fd=%d\n", len, fd);
bytes_written = send (fd, data, len, 0);
if (bytes_written == SOCKET_ERROR)
{
DBUS_SOCKET_SET_ERRNO();
_dbus_verbose ("send: failed: %s\n", _dbus_strerror_from_errno ());
bytes_written = -1;
}
else
_dbus_verbose ("send: = %d\n", bytes_written);
if (bytes_written < 0 && errno == EINTR)
goto again;
#if 0
if (bytes_written > 0)
_dbus_verbose_bytes_of_string (buffer, start, bytes_written);
#endif
return bytes_written;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,035
|
static void dump_backtrace_for_thread(HANDLE hThread)
{
STACKFRAME sf;
CONTEXT context;
DWORD dwImageType;
if (!pStackWalk)
if (!init_backtrace())
return;
/* can't use this function for current thread as GetThreadContext
* doesn't support getting context from current thread */
if (hThread == GetCurrentThread())
return;
DPRINTF("Backtrace:\n");
_DBUS_ZERO(context);
context.ContextFlags = CONTEXT_FULL;
SuspendThread(hThread);
if (!GetThreadContext(hThread, &context))
{
DPRINTF("Couldn't get thread context (error %ld)\n", GetLastError());
ResumeThread(hThread);
return;
}
_DBUS_ZERO(sf);
#ifdef __i386__
sf.AddrFrame.Offset = context.Ebp;
sf.AddrFrame.Mode = AddrModeFlat;
sf.AddrPC.Offset = context.Eip;
sf.AddrPC.Mode = AddrModeFlat;
dwImageType = IMAGE_FILE_MACHINE_I386;
#elif _M_X64
dwImageType = IMAGE_FILE_MACHINE_AMD64;
sf.AddrPC.Offset = context.Rip;
sf.AddrPC.Mode = AddrModeFlat;
sf.AddrFrame.Offset = context.Rsp;
sf.AddrFrame.Mode = AddrModeFlat;
sf.AddrStack.Offset = context.Rsp;
sf.AddrStack.Mode = AddrModeFlat;
#elif _M_IA64
dwImageType = IMAGE_FILE_MACHINE_IA64;
sf.AddrPC.Offset = context.StIIP;
sf.AddrPC.Mode = AddrModeFlat;
sf.AddrFrame.Offset = context.IntSp;
sf.AddrFrame.Mode = AddrModeFlat;
sf.AddrBStore.Offset= context.RsBSP;
sf.AddrBStore.Mode = AddrModeFlat;
sf.AddrStack.Offset = context.IntSp;
sf.AddrStack.Mode = AddrModeFlat;
#else
# error You need to fill in the STACKFRAME structure for your architecture
#endif
while (pStackWalk(dwImageType, GetCurrentProcess(),
hThread, &sf, &context, NULL, pSymFunctionTableAccess,
pSymGetModuleBase, NULL))
{
BYTE buffer[256];
IMAGEHLP_SYMBOL * pSymbol = (IMAGEHLP_SYMBOL *)buffer;
DWORD dwDisplacement;
pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
pSymbol->MaxNameLength = sizeof(buffer) - sizeof(IMAGEHLP_SYMBOL) + 1;
if (!pSymGetSymFromAddr(GetCurrentProcess(), sf.AddrPC.Offset,
&dwDisplacement, pSymbol))
{
IMAGEHLP_MODULE ModuleInfo;
ModuleInfo.SizeOfStruct = sizeof(ModuleInfo);
if (!pSymGetModuleInfo(GetCurrentProcess(), sf.AddrPC.Offset,
&ModuleInfo))
DPRINTF("1\t%p\n", (void*)sf.AddrPC.Offset);
else
DPRINTF("2\t%s+0x%lx\n", ModuleInfo.ImageName,
sf.AddrPC.Offset - ModuleInfo.BaseOfImage);
}
else if (dwDisplacement)
DPRINTF("3\t%s+0x%lx\n", pSymbol->Name, dwDisplacement);
else
DPRINTF("4\t%s\n", pSymbol->Name);
}
ResumeThread(hThread);
}
|
DoS
| 0
|
static void dump_backtrace_for_thread(HANDLE hThread)
{
STACKFRAME sf;
CONTEXT context;
DWORD dwImageType;
if (!pStackWalk)
if (!init_backtrace())
return;
/* can't use this function for current thread as GetThreadContext
* doesn't support getting context from current thread */
if (hThread == GetCurrentThread())
return;
DPRINTF("Backtrace:\n");
_DBUS_ZERO(context);
context.ContextFlags = CONTEXT_FULL;
SuspendThread(hThread);
if (!GetThreadContext(hThread, &context))
{
DPRINTF("Couldn't get thread context (error %ld)\n", GetLastError());
ResumeThread(hThread);
return;
}
_DBUS_ZERO(sf);
#ifdef __i386__
sf.AddrFrame.Offset = context.Ebp;
sf.AddrFrame.Mode = AddrModeFlat;
sf.AddrPC.Offset = context.Eip;
sf.AddrPC.Mode = AddrModeFlat;
dwImageType = IMAGE_FILE_MACHINE_I386;
#elif _M_X64
dwImageType = IMAGE_FILE_MACHINE_AMD64;
sf.AddrPC.Offset = context.Rip;
sf.AddrPC.Mode = AddrModeFlat;
sf.AddrFrame.Offset = context.Rsp;
sf.AddrFrame.Mode = AddrModeFlat;
sf.AddrStack.Offset = context.Rsp;
sf.AddrStack.Mode = AddrModeFlat;
#elif _M_IA64
dwImageType = IMAGE_FILE_MACHINE_IA64;
sf.AddrPC.Offset = context.StIIP;
sf.AddrPC.Mode = AddrModeFlat;
sf.AddrFrame.Offset = context.IntSp;
sf.AddrFrame.Mode = AddrModeFlat;
sf.AddrBStore.Offset= context.RsBSP;
sf.AddrBStore.Mode = AddrModeFlat;
sf.AddrStack.Offset = context.IntSp;
sf.AddrStack.Mode = AddrModeFlat;
#else
# error You need to fill in the STACKFRAME structure for your architecture
#endif
while (pStackWalk(dwImageType, GetCurrentProcess(),
hThread, &sf, &context, NULL, pSymFunctionTableAccess,
pSymGetModuleBase, NULL))
{
BYTE buffer[256];
IMAGEHLP_SYMBOL * pSymbol = (IMAGEHLP_SYMBOL *)buffer;
DWORD dwDisplacement;
pSymbol->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
pSymbol->MaxNameLength = sizeof(buffer) - sizeof(IMAGEHLP_SYMBOL) + 1;
if (!pSymGetSymFromAddr(GetCurrentProcess(), sf.AddrPC.Offset,
&dwDisplacement, pSymbol))
{
IMAGEHLP_MODULE ModuleInfo;
ModuleInfo.SizeOfStruct = sizeof(ModuleInfo);
if (!pSymGetModuleInfo(GetCurrentProcess(), sf.AddrPC.Offset,
&ModuleInfo))
DPRINTF("1\t%p\n", (void*)sf.AddrPC.Offset);
else
DPRINTF("2\t%s+0x%lx\n", ModuleInfo.ImageName,
sf.AddrPC.Offset - ModuleInfo.BaseOfImage);
}
else if (dwDisplacement)
DPRINTF("3\t%s+0x%lx\n", pSymbol->Name, dwDisplacement);
else
DPRINTF("4\t%s\n", pSymbol->Name);
}
ResumeThread(hThread);
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,036
|
static dbus_uint32_t fromAscii(char ascii)
{
if(ascii >= '0' && ascii <= '9')
return ascii - '0';
if(ascii >= 'A' && ascii <= 'F')
return ascii - 'A' + 10;
if(ascii >= 'a' && ascii <= 'f')
return ascii - 'a' + 10;
return 0;
}
|
DoS
| 0
|
static dbus_uint32_t fromAscii(char ascii)
{
if(ascii >= '0' && ascii <= '9')
return ascii - '0';
if(ascii >= 'A' && ascii <= 'F')
return ascii - 'A' + 10;
if(ascii >= 'a' && ascii <= 'f')
return ascii - 'a' + 10;
return 0;
}
|
@@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format,
char buf[1024];
int bufsize;
int len;
+ va_list args_copy;
bufsize = sizeof (buf);
- len = _vsnprintf (buf, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (buf, bufsize - 1, format, args_copy);
+ va_end (args_copy);
while (len == -1) /* try again */
{
@@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format,
if (p == NULL)
return -1;
- len = _vsnprintf (p, bufsize - 1, format, args);
+ DBUS_VA_COPY (args_copy, args);
+ len = _vsnprintf (p, bufsize - 1, format, args_copy);
+ va_end (args_copy);
free (p);
}
|
CWE-20
| null | null |
3,037
|
static void ga_wait_child(pid_t pid, int *status, Error **err)
{
pid_t rpid;
*status = 0;
do {
rpid = waitpid(pid, status, 0);
} while (rpid == -1 && errno == EINTR);
if (rpid == -1) {
error_setg_errno(err, errno, "failed to wait for child (pid: %d)", pid);
return;
}
g_assert(rpid == pid);
}
| null | 0
|
static void ga_wait_child(pid_t pid, int *status, Error **err)
{
pid_t rpid;
*status = 0;
do {
rpid = waitpid(pid, status, 0);
} while (rpid == -1 && errno == EINTR);
if (rpid == -1) {
error_setg_errno(err, errno, "failed to wait for child (pid: %d)", pid);
return;
}
g_assert(rpid == pid);
}
|
@@ -18,6 +18,9 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
#include <inttypes.h>
#include "qga/guest-agent-core.h"
#include "qga-qmp-commands.h"
@@ -237,9 +240,122 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
return NULL;
}
+typedef const char * const ccpc;
+
+/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */
+static const struct {
+ ccpc *forms;
+ int oflag_base;
+} guest_file_open_modes[] = {
+ { (ccpc[]){ "r", "rb", NULL }, O_RDONLY },
+ { (ccpc[]){ "w", "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a", "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND },
+ { (ccpc[]){ "r+", "rb+", "r+b", NULL }, O_RDWR },
+ { (ccpc[]){ "w+", "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a+", "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND }
+};
+
+static int
+find_open_flag(const char *mode_str, Error **err)
+{
+ unsigned mode;
+
+ for (mode = 0; mode < ARRAY_SIZE(guest_file_open_modes); ++mode) {
+ ccpc *form;
+
+ form = guest_file_open_modes[mode].forms;
+ while (*form != NULL && strcmp(*form, mode_str) != 0) {
+ ++form;
+ }
+ if (*form != NULL) {
+ break;
+ }
+ }
+
+ if (mode == ARRAY_SIZE(guest_file_open_modes)) {
+ error_setg(err, "invalid file open mode '%s'", mode_str);
+ return -1;
+ }
+ return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
+}
+
+#define DEFAULT_NEW_FILE_MODE (S_IRUSR | S_IWUSR | \
+ S_IRGRP | S_IWGRP | \
+ S_IROTH | S_IWOTH)
+
+static FILE *
+safe_open_or_create(const char *path, const char *mode, Error **err)
+{
+ Error *local_err = NULL;
+ int oflag;
+
+ oflag = find_open_flag(mode, &local_err);
+ if (local_err == NULL) {
+ int fd;
+
+ /* If the caller wants / allows creation of a new file, we implement it
+ * with a two step process: open() + (open() / fchmod()).
+ *
+ * First we insist on creating the file exclusively as a new file. If
+ * that succeeds, we're free to set any file-mode bits on it. (The
+ * motivation is that we want to set those file-mode bits independently
+ * of the current umask.)
+ *
+ * If the exclusive creation fails because the file already exists
+ * (EEXIST is not possible for any other reason), we just attempt to
+ * open the file, but in this case we won't be allowed to change the
+ * file-mode bits on the preexistent file.
+ *
+ * The pathname should never disappear between the two open()s in
+ * practice. If it happens, then someone very likely tried to race us.
+ * In this case just go ahead and report the ENOENT from the second
+ * open() to the caller.
+ *
+ * If the caller wants to open a preexistent file, then the first
+ * open() is decisive and its third argument is ignored, and the second
+ * open() and the fchmod() are never called.
+ */
+ fd = open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0);
+ if (fd == -1 && errno == EEXIST) {
+ oflag &= ~(unsigned)O_CREAT;
+ fd = open(path, oflag);
+ }
+
+ if (fd == -1) {
+ error_setg_errno(&local_err, errno, "failed to open file '%s' "
+ "(mode: '%s')", path, mode);
+ } else {
+ qemu_set_cloexec(fd);
+
+ if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) == -1) {
+ error_setg_errno(&local_err, errno, "failed to set permission "
+ "0%03o on new file '%s' (mode: '%s')",
+ (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
+ } else {
+ FILE *f;
+
+ f = fdopen(fd, mode);
+ if (f == NULL) {
+ error_setg_errno(&local_err, errno, "failed to associate "
+ "stdio stream with file descriptor %d, "
+ "file '%s' (mode: '%s')", fd, path, mode);
+ } else {
+ return f;
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+ error_propagate(err, local_err);
+ return NULL;
+}
+
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
{
FILE *fh;
+ Error *local_err = NULL;
int fd;
int64_t ret = -1, handle;
@@ -247,10 +363,9 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
- fh = fopen(path, mode);
- if (!fh) {
- error_setg_errno(err, errno, "failed to open file '%s' (mode: '%s')",
- path, mode);
+ fh = safe_open_or_create(path, mode, &local_err);
+ if (local_err != NULL) {
+ error_propagate(err, local_err);
return -1;
}
|
CWE-264
| null | null |
3,038
|
static int64_t guest_file_handle_add(FILE *fh, Error **errp)
{
GuestFileHandle *gfh;
int64_t handle;
handle = ga_get_fd_handle(ga_state, errp);
if (error_is_set(errp)) {
return 0;
}
gfh = g_malloc0(sizeof(GuestFileHandle));
gfh->id = handle;
gfh->fh = fh;
QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next);
return handle;
}
| null | 0
|
static int64_t guest_file_handle_add(FILE *fh, Error **errp)
{
GuestFileHandle *gfh;
int64_t handle;
handle = ga_get_fd_handle(ga_state, errp);
if (error_is_set(errp)) {
return 0;
}
gfh = g_malloc0(sizeof(GuestFileHandle));
gfh->id = handle;
gfh->fh = fh;
QTAILQ_INSERT_TAIL(&guest_file_state.filehandles, gfh, next);
return handle;
}
|
@@ -18,6 +18,9 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
#include <inttypes.h>
#include "qga/guest-agent-core.h"
#include "qga-qmp-commands.h"
@@ -237,9 +240,122 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
return NULL;
}
+typedef const char * const ccpc;
+
+/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */
+static const struct {
+ ccpc *forms;
+ int oflag_base;
+} guest_file_open_modes[] = {
+ { (ccpc[]){ "r", "rb", NULL }, O_RDONLY },
+ { (ccpc[]){ "w", "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a", "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND },
+ { (ccpc[]){ "r+", "rb+", "r+b", NULL }, O_RDWR },
+ { (ccpc[]){ "w+", "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a+", "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND }
+};
+
+static int
+find_open_flag(const char *mode_str, Error **err)
+{
+ unsigned mode;
+
+ for (mode = 0; mode < ARRAY_SIZE(guest_file_open_modes); ++mode) {
+ ccpc *form;
+
+ form = guest_file_open_modes[mode].forms;
+ while (*form != NULL && strcmp(*form, mode_str) != 0) {
+ ++form;
+ }
+ if (*form != NULL) {
+ break;
+ }
+ }
+
+ if (mode == ARRAY_SIZE(guest_file_open_modes)) {
+ error_setg(err, "invalid file open mode '%s'", mode_str);
+ return -1;
+ }
+ return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
+}
+
+#define DEFAULT_NEW_FILE_MODE (S_IRUSR | S_IWUSR | \
+ S_IRGRP | S_IWGRP | \
+ S_IROTH | S_IWOTH)
+
+static FILE *
+safe_open_or_create(const char *path, const char *mode, Error **err)
+{
+ Error *local_err = NULL;
+ int oflag;
+
+ oflag = find_open_flag(mode, &local_err);
+ if (local_err == NULL) {
+ int fd;
+
+ /* If the caller wants / allows creation of a new file, we implement it
+ * with a two step process: open() + (open() / fchmod()).
+ *
+ * First we insist on creating the file exclusively as a new file. If
+ * that succeeds, we're free to set any file-mode bits on it. (The
+ * motivation is that we want to set those file-mode bits independently
+ * of the current umask.)
+ *
+ * If the exclusive creation fails because the file already exists
+ * (EEXIST is not possible for any other reason), we just attempt to
+ * open the file, but in this case we won't be allowed to change the
+ * file-mode bits on the preexistent file.
+ *
+ * The pathname should never disappear between the two open()s in
+ * practice. If it happens, then someone very likely tried to race us.
+ * In this case just go ahead and report the ENOENT from the second
+ * open() to the caller.
+ *
+ * If the caller wants to open a preexistent file, then the first
+ * open() is decisive and its third argument is ignored, and the second
+ * open() and the fchmod() are never called.
+ */
+ fd = open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0);
+ if (fd == -1 && errno == EEXIST) {
+ oflag &= ~(unsigned)O_CREAT;
+ fd = open(path, oflag);
+ }
+
+ if (fd == -1) {
+ error_setg_errno(&local_err, errno, "failed to open file '%s' "
+ "(mode: '%s')", path, mode);
+ } else {
+ qemu_set_cloexec(fd);
+
+ if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) == -1) {
+ error_setg_errno(&local_err, errno, "failed to set permission "
+ "0%03o on new file '%s' (mode: '%s')",
+ (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
+ } else {
+ FILE *f;
+
+ f = fdopen(fd, mode);
+ if (f == NULL) {
+ error_setg_errno(&local_err, errno, "failed to associate "
+ "stdio stream with file descriptor %d, "
+ "file '%s' (mode: '%s')", fd, path, mode);
+ } else {
+ return f;
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+ error_propagate(err, local_err);
+ return NULL;
+}
+
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
{
FILE *fh;
+ Error *local_err = NULL;
int fd;
int64_t ret = -1, handle;
@@ -247,10 +363,9 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
- fh = fopen(path, mode);
- if (!fh) {
- error_setg_errno(err, errno, "failed to open file '%s' (mode: '%s')",
- path, mode);
+ fh = safe_open_or_create(path, mode, &local_err);
+ if (local_err != NULL) {
+ error_propagate(err, local_err);
return -1;
}
|
CWE-264
| null | null |
3,039
|
static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
{
GuestFileHandle *gfh;
QTAILQ_FOREACH(gfh, &guest_file_state.filehandles, next)
{
if (gfh->id == id) {
return gfh;
}
}
error_setg(err, "handle '%" PRId64 "' has not been found", id);
return NULL;
}
| null | 0
|
static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
{
GuestFileHandle *gfh;
QTAILQ_FOREACH(gfh, &guest_file_state.filehandles, next)
{
if (gfh->id == id) {
return gfh;
}
}
error_setg(err, "handle '%" PRId64 "' has not been found", id);
return NULL;
}
|
@@ -18,6 +18,9 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
#include <inttypes.h>
#include "qga/guest-agent-core.h"
#include "qga-qmp-commands.h"
@@ -237,9 +240,122 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
return NULL;
}
+typedef const char * const ccpc;
+
+/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */
+static const struct {
+ ccpc *forms;
+ int oflag_base;
+} guest_file_open_modes[] = {
+ { (ccpc[]){ "r", "rb", NULL }, O_RDONLY },
+ { (ccpc[]){ "w", "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a", "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND },
+ { (ccpc[]){ "r+", "rb+", "r+b", NULL }, O_RDWR },
+ { (ccpc[]){ "w+", "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a+", "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND }
+};
+
+static int
+find_open_flag(const char *mode_str, Error **err)
+{
+ unsigned mode;
+
+ for (mode = 0; mode < ARRAY_SIZE(guest_file_open_modes); ++mode) {
+ ccpc *form;
+
+ form = guest_file_open_modes[mode].forms;
+ while (*form != NULL && strcmp(*form, mode_str) != 0) {
+ ++form;
+ }
+ if (*form != NULL) {
+ break;
+ }
+ }
+
+ if (mode == ARRAY_SIZE(guest_file_open_modes)) {
+ error_setg(err, "invalid file open mode '%s'", mode_str);
+ return -1;
+ }
+ return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
+}
+
+#define DEFAULT_NEW_FILE_MODE (S_IRUSR | S_IWUSR | \
+ S_IRGRP | S_IWGRP | \
+ S_IROTH | S_IWOTH)
+
+static FILE *
+safe_open_or_create(const char *path, const char *mode, Error **err)
+{
+ Error *local_err = NULL;
+ int oflag;
+
+ oflag = find_open_flag(mode, &local_err);
+ if (local_err == NULL) {
+ int fd;
+
+ /* If the caller wants / allows creation of a new file, we implement it
+ * with a two step process: open() + (open() / fchmod()).
+ *
+ * First we insist on creating the file exclusively as a new file. If
+ * that succeeds, we're free to set any file-mode bits on it. (The
+ * motivation is that we want to set those file-mode bits independently
+ * of the current umask.)
+ *
+ * If the exclusive creation fails because the file already exists
+ * (EEXIST is not possible for any other reason), we just attempt to
+ * open the file, but in this case we won't be allowed to change the
+ * file-mode bits on the preexistent file.
+ *
+ * The pathname should never disappear between the two open()s in
+ * practice. If it happens, then someone very likely tried to race us.
+ * In this case just go ahead and report the ENOENT from the second
+ * open() to the caller.
+ *
+ * If the caller wants to open a preexistent file, then the first
+ * open() is decisive and its third argument is ignored, and the second
+ * open() and the fchmod() are never called.
+ */
+ fd = open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0);
+ if (fd == -1 && errno == EEXIST) {
+ oflag &= ~(unsigned)O_CREAT;
+ fd = open(path, oflag);
+ }
+
+ if (fd == -1) {
+ error_setg_errno(&local_err, errno, "failed to open file '%s' "
+ "(mode: '%s')", path, mode);
+ } else {
+ qemu_set_cloexec(fd);
+
+ if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) == -1) {
+ error_setg_errno(&local_err, errno, "failed to set permission "
+ "0%03o on new file '%s' (mode: '%s')",
+ (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
+ } else {
+ FILE *f;
+
+ f = fdopen(fd, mode);
+ if (f == NULL) {
+ error_setg_errno(&local_err, errno, "failed to associate "
+ "stdio stream with file descriptor %d, "
+ "file '%s' (mode: '%s')", fd, path, mode);
+ } else {
+ return f;
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+ error_propagate(err, local_err);
+ return NULL;
+}
+
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
{
FILE *fh;
+ Error *local_err = NULL;
int fd;
int64_t ret = -1, handle;
@@ -247,10 +363,9 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
- fh = fopen(path, mode);
- if (!fh) {
- error_setg_errno(err, errno, "failed to open file '%s' (mode: '%s')",
- path, mode);
+ fh = safe_open_or_create(path, mode, &local_err);
+ if (local_err != NULL) {
+ error_propagate(err, local_err);
return -1;
}
|
CWE-264
| null | null |
3,040
|
int64_t qmp_guest_get_time(Error **errp)
{
int ret;
qemu_timeval tq;
int64_t time_ns;
ret = qemu_gettimeofday(&tq);
if (ret < 0) {
error_setg_errno(errp, errno, "Failed to get time");
return -1;
}
time_ns = tq.tv_sec * 1000000000LL + tq.tv_usec * 1000;
return time_ns;
}
| null | 0
|
int64_t qmp_guest_get_time(Error **errp)
{
int ret;
qemu_timeval tq;
int64_t time_ns;
ret = qemu_gettimeofday(&tq);
if (ret < 0) {
error_setg_errno(errp, errno, "Failed to get time");
return -1;
}
time_ns = tq.tv_sec * 1000000000LL + tq.tv_usec * 1000;
return time_ns;
}
|
@@ -18,6 +18,9 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
#include <inttypes.h>
#include "qga/guest-agent-core.h"
#include "qga-qmp-commands.h"
@@ -237,9 +240,122 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
return NULL;
}
+typedef const char * const ccpc;
+
+/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */
+static const struct {
+ ccpc *forms;
+ int oflag_base;
+} guest_file_open_modes[] = {
+ { (ccpc[]){ "r", "rb", NULL }, O_RDONLY },
+ { (ccpc[]){ "w", "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a", "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND },
+ { (ccpc[]){ "r+", "rb+", "r+b", NULL }, O_RDWR },
+ { (ccpc[]){ "w+", "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a+", "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND }
+};
+
+static int
+find_open_flag(const char *mode_str, Error **err)
+{
+ unsigned mode;
+
+ for (mode = 0; mode < ARRAY_SIZE(guest_file_open_modes); ++mode) {
+ ccpc *form;
+
+ form = guest_file_open_modes[mode].forms;
+ while (*form != NULL && strcmp(*form, mode_str) != 0) {
+ ++form;
+ }
+ if (*form != NULL) {
+ break;
+ }
+ }
+
+ if (mode == ARRAY_SIZE(guest_file_open_modes)) {
+ error_setg(err, "invalid file open mode '%s'", mode_str);
+ return -1;
+ }
+ return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
+}
+
+#define DEFAULT_NEW_FILE_MODE (S_IRUSR | S_IWUSR | \
+ S_IRGRP | S_IWGRP | \
+ S_IROTH | S_IWOTH)
+
+static FILE *
+safe_open_or_create(const char *path, const char *mode, Error **err)
+{
+ Error *local_err = NULL;
+ int oflag;
+
+ oflag = find_open_flag(mode, &local_err);
+ if (local_err == NULL) {
+ int fd;
+
+ /* If the caller wants / allows creation of a new file, we implement it
+ * with a two step process: open() + (open() / fchmod()).
+ *
+ * First we insist on creating the file exclusively as a new file. If
+ * that succeeds, we're free to set any file-mode bits on it. (The
+ * motivation is that we want to set those file-mode bits independently
+ * of the current umask.)
+ *
+ * If the exclusive creation fails because the file already exists
+ * (EEXIST is not possible for any other reason), we just attempt to
+ * open the file, but in this case we won't be allowed to change the
+ * file-mode bits on the preexistent file.
+ *
+ * The pathname should never disappear between the two open()s in
+ * practice. If it happens, then someone very likely tried to race us.
+ * In this case just go ahead and report the ENOENT from the second
+ * open() to the caller.
+ *
+ * If the caller wants to open a preexistent file, then the first
+ * open() is decisive and its third argument is ignored, and the second
+ * open() and the fchmod() are never called.
+ */
+ fd = open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0);
+ if (fd == -1 && errno == EEXIST) {
+ oflag &= ~(unsigned)O_CREAT;
+ fd = open(path, oflag);
+ }
+
+ if (fd == -1) {
+ error_setg_errno(&local_err, errno, "failed to open file '%s' "
+ "(mode: '%s')", path, mode);
+ } else {
+ qemu_set_cloexec(fd);
+
+ if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) == -1) {
+ error_setg_errno(&local_err, errno, "failed to set permission "
+ "0%03o on new file '%s' (mode: '%s')",
+ (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
+ } else {
+ FILE *f;
+
+ f = fdopen(fd, mode);
+ if (f == NULL) {
+ error_setg_errno(&local_err, errno, "failed to associate "
+ "stdio stream with file descriptor %d, "
+ "file '%s' (mode: '%s')", fd, path, mode);
+ } else {
+ return f;
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+ error_propagate(err, local_err);
+ return NULL;
+}
+
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
{
FILE *fh;
+ Error *local_err = NULL;
int fd;
int64_t ret = -1, handle;
@@ -247,10 +363,9 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
- fh = fopen(path, mode);
- if (!fh) {
- error_setg_errno(err, errno, "failed to open file '%s' (mode: '%s')",
- path, mode);
+ fh = safe_open_or_create(path, mode, &local_err);
+ if (local_err != NULL) {
+ error_propagate(err, local_err);
return -1;
}
|
CWE-264
| null | null |
3,041
|
void qmp_guest_set_time(int64_t time_ns, Error **errp)
{
int ret;
int status;
pid_t pid;
Error *local_err = NULL;
struct timeval tv;
/* year-2038 will overflow in case time_t is 32bit */
if (time_ns / 1000000000 != (time_t)(time_ns / 1000000000)) {
error_setg(errp, "Time %" PRId64 " is too large", time_ns);
return;
}
tv.tv_sec = time_ns / 1000000000;
tv.tv_usec = (time_ns % 1000000000) / 1000;
ret = settimeofday(&tv, NULL);
if (ret < 0) {
error_setg_errno(errp, errno, "Failed to set time to guest");
return;
}
/* Set the Hardware Clock to the current System Time. */
pid = fork();
if (pid == 0) {
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
execle("/sbin/hwclock", "hwclock", "-w", NULL, environ);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(errp, errno, "failed to create child process");
return;
}
ga_wait_child(pid, &status, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
if (!WIFEXITED(status)) {
error_setg(errp, "child process has terminated abnormally");
return;
}
if (WEXITSTATUS(status)) {
error_setg(errp, "hwclock failed to set hardware clock to system time");
return;
}
}
| null | 0
|
void qmp_guest_set_time(int64_t time_ns, Error **errp)
{
int ret;
int status;
pid_t pid;
Error *local_err = NULL;
struct timeval tv;
/* year-2038 will overflow in case time_t is 32bit */
if (time_ns / 1000000000 != (time_t)(time_ns / 1000000000)) {
error_setg(errp, "Time %" PRId64 " is too large", time_ns);
return;
}
tv.tv_sec = time_ns / 1000000000;
tv.tv_usec = (time_ns % 1000000000) / 1000;
ret = settimeofday(&tv, NULL);
if (ret < 0) {
error_setg_errno(errp, errno, "Failed to set time to guest");
return;
}
/* Set the Hardware Clock to the current System Time. */
pid = fork();
if (pid == 0) {
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
execle("/sbin/hwclock", "hwclock", "-w", NULL, environ);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(errp, errno, "failed to create child process");
return;
}
ga_wait_child(pid, &status, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
return;
}
if (!WIFEXITED(status)) {
error_setg(errp, "child process has terminated abnormally");
return;
}
if (WEXITSTATUS(status)) {
error_setg(errp, "hwclock failed to set hardware clock to system time");
return;
}
}
|
@@ -18,6 +18,9 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
#include <inttypes.h>
#include "qga/guest-agent-core.h"
#include "qga-qmp-commands.h"
@@ -237,9 +240,122 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
return NULL;
}
+typedef const char * const ccpc;
+
+/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */
+static const struct {
+ ccpc *forms;
+ int oflag_base;
+} guest_file_open_modes[] = {
+ { (ccpc[]){ "r", "rb", NULL }, O_RDONLY },
+ { (ccpc[]){ "w", "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a", "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND },
+ { (ccpc[]){ "r+", "rb+", "r+b", NULL }, O_RDWR },
+ { (ccpc[]){ "w+", "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a+", "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND }
+};
+
+static int
+find_open_flag(const char *mode_str, Error **err)
+{
+ unsigned mode;
+
+ for (mode = 0; mode < ARRAY_SIZE(guest_file_open_modes); ++mode) {
+ ccpc *form;
+
+ form = guest_file_open_modes[mode].forms;
+ while (*form != NULL && strcmp(*form, mode_str) != 0) {
+ ++form;
+ }
+ if (*form != NULL) {
+ break;
+ }
+ }
+
+ if (mode == ARRAY_SIZE(guest_file_open_modes)) {
+ error_setg(err, "invalid file open mode '%s'", mode_str);
+ return -1;
+ }
+ return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
+}
+
+#define DEFAULT_NEW_FILE_MODE (S_IRUSR | S_IWUSR | \
+ S_IRGRP | S_IWGRP | \
+ S_IROTH | S_IWOTH)
+
+static FILE *
+safe_open_or_create(const char *path, const char *mode, Error **err)
+{
+ Error *local_err = NULL;
+ int oflag;
+
+ oflag = find_open_flag(mode, &local_err);
+ if (local_err == NULL) {
+ int fd;
+
+ /* If the caller wants / allows creation of a new file, we implement it
+ * with a two step process: open() + (open() / fchmod()).
+ *
+ * First we insist on creating the file exclusively as a new file. If
+ * that succeeds, we're free to set any file-mode bits on it. (The
+ * motivation is that we want to set those file-mode bits independently
+ * of the current umask.)
+ *
+ * If the exclusive creation fails because the file already exists
+ * (EEXIST is not possible for any other reason), we just attempt to
+ * open the file, but in this case we won't be allowed to change the
+ * file-mode bits on the preexistent file.
+ *
+ * The pathname should never disappear between the two open()s in
+ * practice. If it happens, then someone very likely tried to race us.
+ * In this case just go ahead and report the ENOENT from the second
+ * open() to the caller.
+ *
+ * If the caller wants to open a preexistent file, then the first
+ * open() is decisive and its third argument is ignored, and the second
+ * open() and the fchmod() are never called.
+ */
+ fd = open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0);
+ if (fd == -1 && errno == EEXIST) {
+ oflag &= ~(unsigned)O_CREAT;
+ fd = open(path, oflag);
+ }
+
+ if (fd == -1) {
+ error_setg_errno(&local_err, errno, "failed to open file '%s' "
+ "(mode: '%s')", path, mode);
+ } else {
+ qemu_set_cloexec(fd);
+
+ if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) == -1) {
+ error_setg_errno(&local_err, errno, "failed to set permission "
+ "0%03o on new file '%s' (mode: '%s')",
+ (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
+ } else {
+ FILE *f;
+
+ f = fdopen(fd, mode);
+ if (f == NULL) {
+ error_setg_errno(&local_err, errno, "failed to associate "
+ "stdio stream with file descriptor %d, "
+ "file '%s' (mode: '%s')", fd, path, mode);
+ } else {
+ return f;
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+ error_propagate(err, local_err);
+ return NULL;
+}
+
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
{
FILE *fh;
+ Error *local_err = NULL;
int fd;
int64_t ret = -1, handle;
@@ -247,10 +363,9 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
- fh = fopen(path, mode);
- if (!fh) {
- error_setg_errno(err, errno, "failed to open file '%s' (mode: '%s')",
- path, mode);
+ fh = safe_open_or_create(path, mode, &local_err);
+ if (local_err != NULL) {
+ error_propagate(err, local_err);
return -1;
}
|
CWE-264
| null | null |
3,042
|
void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
{
const char *shutdown_flag;
Error *local_err = NULL;
pid_t pid;
int status;
slog("guest-shutdown called, mode: %s", mode);
if (!has_mode || strcmp(mode, "powerdown") == 0) {
shutdown_flag = "-P";
} else if (strcmp(mode, "halt") == 0) {
shutdown_flag = "-H";
} else if (strcmp(mode, "reboot") == 0) {
shutdown_flag = "-r";
} else {
error_setg(err,
"mode is invalid (valid values are: halt|powerdown|reboot");
return;
}
pid = fork();
if (pid == 0) {
/* child, start the shutdown */
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
"hypervisor initiated shutdown", (char*)NULL, environ);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(err, errno, "failed to create child process");
return;
}
ga_wait_child(pid, &status, &local_err);
if (error_is_set(&local_err)) {
error_propagate(err, local_err);
return;
}
if (!WIFEXITED(status)) {
error_setg(err, "child process has terminated abnormally");
return;
}
if (WEXITSTATUS(status)) {
error_setg(err, "child process has failed to shutdown");
return;
}
/* succeeded */
}
| null | 0
|
void qmp_guest_shutdown(bool has_mode, const char *mode, Error **err)
{
const char *shutdown_flag;
Error *local_err = NULL;
pid_t pid;
int status;
slog("guest-shutdown called, mode: %s", mode);
if (!has_mode || strcmp(mode, "powerdown") == 0) {
shutdown_flag = "-P";
} else if (strcmp(mode, "halt") == 0) {
shutdown_flag = "-H";
} else if (strcmp(mode, "reboot") == 0) {
shutdown_flag = "-r";
} else {
error_setg(err,
"mode is invalid (valid values are: halt|powerdown|reboot");
return;
}
pid = fork();
if (pid == 0) {
/* child, start the shutdown */
setsid();
reopen_fd_to_null(0);
reopen_fd_to_null(1);
reopen_fd_to_null(2);
execle("/sbin/shutdown", "shutdown", shutdown_flag, "+0",
"hypervisor initiated shutdown", (char*)NULL, environ);
_exit(EXIT_FAILURE);
} else if (pid < 0) {
error_setg_errno(err, errno, "failed to create child process");
return;
}
ga_wait_child(pid, &status, &local_err);
if (error_is_set(&local_err)) {
error_propagate(err, local_err);
return;
}
if (!WIFEXITED(status)) {
error_setg(err, "child process has terminated abnormally");
return;
}
if (WEXITSTATUS(status)) {
error_setg(err, "child process has failed to shutdown");
return;
}
/* succeeded */
}
|
@@ -18,6 +18,9 @@
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
#include <inttypes.h>
#include "qga/guest-agent-core.h"
#include "qga-qmp-commands.h"
@@ -237,9 +240,122 @@ static GuestFileHandle *guest_file_handle_find(int64_t id, Error **err)
return NULL;
}
+typedef const char * const ccpc;
+
+/* http://pubs.opengroup.org/onlinepubs/9699919799/functions/fopen.html */
+static const struct {
+ ccpc *forms;
+ int oflag_base;
+} guest_file_open_modes[] = {
+ { (ccpc[]){ "r", "rb", NULL }, O_RDONLY },
+ { (ccpc[]){ "w", "wb", NULL }, O_WRONLY | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a", "ab", NULL }, O_WRONLY | O_CREAT | O_APPEND },
+ { (ccpc[]){ "r+", "rb+", "r+b", NULL }, O_RDWR },
+ { (ccpc[]){ "w+", "wb+", "w+b", NULL }, O_RDWR | O_CREAT | O_TRUNC },
+ { (ccpc[]){ "a+", "ab+", "a+b", NULL }, O_RDWR | O_CREAT | O_APPEND }
+};
+
+static int
+find_open_flag(const char *mode_str, Error **err)
+{
+ unsigned mode;
+
+ for (mode = 0; mode < ARRAY_SIZE(guest_file_open_modes); ++mode) {
+ ccpc *form;
+
+ form = guest_file_open_modes[mode].forms;
+ while (*form != NULL && strcmp(*form, mode_str) != 0) {
+ ++form;
+ }
+ if (*form != NULL) {
+ break;
+ }
+ }
+
+ if (mode == ARRAY_SIZE(guest_file_open_modes)) {
+ error_setg(err, "invalid file open mode '%s'", mode_str);
+ return -1;
+ }
+ return guest_file_open_modes[mode].oflag_base | O_NOCTTY | O_NONBLOCK;
+}
+
+#define DEFAULT_NEW_FILE_MODE (S_IRUSR | S_IWUSR | \
+ S_IRGRP | S_IWGRP | \
+ S_IROTH | S_IWOTH)
+
+static FILE *
+safe_open_or_create(const char *path, const char *mode, Error **err)
+{
+ Error *local_err = NULL;
+ int oflag;
+
+ oflag = find_open_flag(mode, &local_err);
+ if (local_err == NULL) {
+ int fd;
+
+ /* If the caller wants / allows creation of a new file, we implement it
+ * with a two step process: open() + (open() / fchmod()).
+ *
+ * First we insist on creating the file exclusively as a new file. If
+ * that succeeds, we're free to set any file-mode bits on it. (The
+ * motivation is that we want to set those file-mode bits independently
+ * of the current umask.)
+ *
+ * If the exclusive creation fails because the file already exists
+ * (EEXIST is not possible for any other reason), we just attempt to
+ * open the file, but in this case we won't be allowed to change the
+ * file-mode bits on the preexistent file.
+ *
+ * The pathname should never disappear between the two open()s in
+ * practice. If it happens, then someone very likely tried to race us.
+ * In this case just go ahead and report the ENOENT from the second
+ * open() to the caller.
+ *
+ * If the caller wants to open a preexistent file, then the first
+ * open() is decisive and its third argument is ignored, and the second
+ * open() and the fchmod() are never called.
+ */
+ fd = open(path, oflag | ((oflag & O_CREAT) ? O_EXCL : 0), 0);
+ if (fd == -1 && errno == EEXIST) {
+ oflag &= ~(unsigned)O_CREAT;
+ fd = open(path, oflag);
+ }
+
+ if (fd == -1) {
+ error_setg_errno(&local_err, errno, "failed to open file '%s' "
+ "(mode: '%s')", path, mode);
+ } else {
+ qemu_set_cloexec(fd);
+
+ if ((oflag & O_CREAT) && fchmod(fd, DEFAULT_NEW_FILE_MODE) == -1) {
+ error_setg_errno(&local_err, errno, "failed to set permission "
+ "0%03o on new file '%s' (mode: '%s')",
+ (unsigned)DEFAULT_NEW_FILE_MODE, path, mode);
+ } else {
+ FILE *f;
+
+ f = fdopen(fd, mode);
+ if (f == NULL) {
+ error_setg_errno(&local_err, errno, "failed to associate "
+ "stdio stream with file descriptor %d, "
+ "file '%s' (mode: '%s')", fd, path, mode);
+ } else {
+ return f;
+ }
+ }
+
+ close(fd);
+ }
+ }
+
+ error_propagate(err, local_err);
+ return NULL;
+}
+
int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, Error **err)
{
FILE *fh;
+ Error *local_err = NULL;
int fd;
int64_t ret = -1, handle;
@@ -247,10 +363,9 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E
mode = "r";
}
slog("guest-file-open called, filepath: %s, mode: %s", path, mode);
- fh = fopen(path, mode);
- if (!fh) {
- error_setg_errno(err, errno, "failed to open file '%s' (mode: '%s')",
- path, mode);
+ fh = safe_open_or_create(path, mode, &local_err);
+ if (local_err != NULL) {
+ error_propagate(err, local_err);
return -1;
}
|
CWE-264
| null | null |
3,043
|
static gboolean channel_event_cb(GIOCondition condition, gpointer data)
{
GAState *s = data;
gchar buf[QGA_READ_COUNT_DEFAULT+1];
gsize count;
GError *err = NULL;
GIOStatus status = ga_channel_read(s->channel, buf, QGA_READ_COUNT_DEFAULT, &count);
if (err != NULL) {
g_warning("error reading channel: %s", err->message);
g_error_free(err);
return false;
}
switch (status) {
case G_IO_STATUS_ERROR:
g_warning("error reading channel");
return false;
case G_IO_STATUS_NORMAL:
buf[count] = 0;
g_debug("read data, count: %d, data: %s", (int)count, buf);
json_message_parser_feed(&s->parser, (char *)buf, (int)count);
break;
case G_IO_STATUS_EOF:
g_debug("received EOF");
if (!s->virtio) {
return false;
}
/* fall through */
case G_IO_STATUS_AGAIN:
/* virtio causes us to spin here when no process is attached to
* host-side chardev. sleep a bit to mitigate this
*/
if (s->virtio) {
usleep(100*1000);
}
return true;
default:
g_warning("unknown channel read status, closing");
return false;
}
return true;
}
| null | 0
|
static gboolean channel_event_cb(GIOCondition condition, gpointer data)
{
GAState *s = data;
gchar buf[QGA_READ_COUNT_DEFAULT+1];
gsize count;
GError *err = NULL;
GIOStatus status = ga_channel_read(s->channel, buf, QGA_READ_COUNT_DEFAULT, &count);
if (err != NULL) {
g_warning("error reading channel: %s", err->message);
g_error_free(err);
return false;
}
switch (status) {
case G_IO_STATUS_ERROR:
g_warning("error reading channel");
return false;
case G_IO_STATUS_NORMAL:
buf[count] = 0;
g_debug("read data, count: %d, data: %s", (int)count, buf);
json_message_parser_feed(&s->parser, (char *)buf, (int)count);
break;
case G_IO_STATUS_EOF:
g_debug("received EOF");
if (!s->virtio) {
return false;
}
/* fall through */
case G_IO_STATUS_AGAIN:
/* virtio causes us to spin here when no process is attached to
* host-side chardev. sleep a bit to mitigate this
*/
if (s->virtio) {
usleep(100*1000);
}
return true;
default:
g_warning("unknown channel read status, closing");
return false;
}
return true;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,044
|
static gboolean channel_init(GAState *s, const gchar *method, const gchar *path)
{
GAChannelMethod channel_method;
if (method == NULL) {
method = "virtio-serial";
}
if (path == NULL) {
if (strcmp(method, "virtio-serial") != 0) {
g_critical("must specify a path for this channel");
return false;
}
/* try the default path for the virtio-serial port */
path = QGA_VIRTIO_PATH_DEFAULT;
}
if (strcmp(method, "virtio-serial") == 0) {
s->virtio = true; /* virtio requires special handling in some cases */
channel_method = GA_CHANNEL_VIRTIO_SERIAL;
} else if (strcmp(method, "isa-serial") == 0) {
channel_method = GA_CHANNEL_ISA_SERIAL;
} else if (strcmp(method, "unix-listen") == 0) {
channel_method = GA_CHANNEL_UNIX_LISTEN;
} else {
g_critical("unsupported channel method/type: %s", method);
return false;
}
s->channel = ga_channel_new(channel_method, path, channel_event_cb, s);
if (!s->channel) {
g_critical("failed to create guest agent channel");
return false;
}
return true;
}
| null | 0
|
static gboolean channel_init(GAState *s, const gchar *method, const gchar *path)
{
GAChannelMethod channel_method;
if (method == NULL) {
method = "virtio-serial";
}
if (path == NULL) {
if (strcmp(method, "virtio-serial") != 0) {
g_critical("must specify a path for this channel");
return false;
}
/* try the default path for the virtio-serial port */
path = QGA_VIRTIO_PATH_DEFAULT;
}
if (strcmp(method, "virtio-serial") == 0) {
s->virtio = true; /* virtio requires special handling in some cases */
channel_method = GA_CHANNEL_VIRTIO_SERIAL;
} else if (strcmp(method, "isa-serial") == 0) {
channel_method = GA_CHANNEL_ISA_SERIAL;
} else if (strcmp(method, "unix-listen") == 0) {
channel_method = GA_CHANNEL_UNIX_LISTEN;
} else {
g_critical("unsupported channel method/type: %s", method);
return false;
}
s->channel = ga_channel_new(channel_method, path, channel_event_cb, s);
if (!s->channel) {
g_critical("failed to create guest agent channel");
return false;
}
return true;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,045
|
static bool ga_create_file(const char *path)
{
int fd = open(path, O_CREAT | O_WRONLY, S_IWUSR | S_IRUSR);
if (fd == -1) {
g_warning("unable to open/create file %s: %s", path, strerror(errno));
return false;
}
close(fd);
return true;
}
| null | 0
|
static bool ga_create_file(const char *path)
{
int fd = open(path, O_CREAT | O_WRONLY, S_IWUSR | S_IRUSR);
if (fd == -1) {
g_warning("unable to open/create file %s: %s", path, strerror(errno));
return false;
}
close(fd);
return true;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,046
|
static bool ga_delete_file(const char *path)
{
int ret = unlink(path);
if (ret == -1) {
g_warning("unable to delete file: %s: %s", path, strerror(errno));
return false;
}
return true;
}
| null | 0
|
static bool ga_delete_file(const char *path)
{
int ret = unlink(path);
if (ret == -1) {
g_warning("unable to delete file: %s: %s", path, strerror(errno));
return false;
}
return true;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,047
|
void ga_disable_logging(GAState *s)
{
s->logging_enabled = false;
}
| null | 0
|
void ga_disable_logging(GAState *s)
{
s->logging_enabled = false;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,048
|
static void ga_disable_non_whitelisted(void)
{
char **list_head, **list;
bool whitelisted;
int i;
list_head = list = qmp_get_command_list();
while (*list != NULL) {
whitelisted = false;
i = 0;
while (ga_freeze_whitelist[i] != NULL) {
if (strcmp(*list, ga_freeze_whitelist[i]) == 0) {
whitelisted = true;
}
i++;
}
if (!whitelisted) {
g_debug("disabling command: %s", *list);
qmp_disable_command(*list);
}
g_free(*list);
list++;
}
g_free(list_head);
}
| null | 0
|
static void ga_disable_non_whitelisted(void)
{
char **list_head, **list;
bool whitelisted;
int i;
list_head = list = qmp_get_command_list();
while (*list != NULL) {
whitelisted = false;
i = 0;
while (ga_freeze_whitelist[i] != NULL) {
if (strcmp(*list, ga_freeze_whitelist[i]) == 0) {
whitelisted = true;
}
i++;
}
if (!whitelisted) {
g_debug("disabling command: %s", *list);
qmp_disable_command(*list);
}
g_free(*list);
list++;
}
g_free(list_head);
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,049
|
void ga_enable_logging(GAState *s)
{
s->logging_enabled = true;
}
| null | 0
|
void ga_enable_logging(GAState *s)
{
s->logging_enabled = true;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,050
|
static void ga_enable_non_blacklisted(GList *blacklist)
{
char **list_head, **list;
list_head = list = qmp_get_command_list();
while (*list != NULL) {
if (g_list_find_custom(blacklist, *list, ga_strcmp) == NULL &&
!qmp_command_is_enabled(*list)) {
g_debug("enabling command: %s", *list);
qmp_enable_command(*list);
}
g_free(*list);
list++;
}
g_free(list_head);
}
| null | 0
|
static void ga_enable_non_blacklisted(GList *blacklist)
{
char **list_head, **list;
list_head = list = qmp_get_command_list();
while (*list != NULL) {
if (g_list_find_custom(blacklist, *list, ga_strcmp) == NULL &&
!qmp_command_is_enabled(*list)) {
g_debug("enabling command: %s", *list);
qmp_enable_command(*list);
}
g_free(*list);
list++;
}
g_free(list_head);
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,051
|
const char *ga_fsfreeze_hook(GAState *s)
{
return s->fsfreeze_hook;
}
| null | 0
|
const char *ga_fsfreeze_hook(GAState *s)
{
return s->fsfreeze_hook;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,052
|
int64_t ga_get_fd_handle(GAState *s, Error **errp)
{
int64_t handle;
g_assert(s->pstate_filepath);
/* we blacklist commands and avoid operations that potentially require
* writing to disk when we're in a frozen state. this includes opening
* new files, so we should never get here in that situation
*/
g_assert(!ga_is_frozen(s));
handle = s->pstate.fd_counter++;
/* This should never happen on a reasonable timeframe, as guest-file-open
* would have to be issued 2^63 times */
if (s->pstate.fd_counter == INT64_MAX) {
abort();
}
if (!write_persistent_state(&s->pstate, s->pstate_filepath)) {
error_setg(errp, "failed to commit persistent state to disk");
}
return handle;
}
| null | 0
|
int64_t ga_get_fd_handle(GAState *s, Error **errp)
{
int64_t handle;
g_assert(s->pstate_filepath);
/* we blacklist commands and avoid operations that potentially require
* writing to disk when we're in a frozen state. this includes opening
* new files, so we should never get here in that situation
*/
g_assert(!ga_is_frozen(s));
handle = s->pstate.fd_counter++;
/* This should never happen on a reasonable timeframe, as guest-file-open
* would have to be issued 2^63 times */
if (s->pstate.fd_counter == INT64_MAX) {
abort();
}
if (!write_persistent_state(&s->pstate, s->pstate_filepath)) {
error_setg(errp, "failed to commit persistent state to disk");
}
return handle;
}
|
@@ -478,7 +478,7 @@ static void become_daemon(const char *pidfile)
}
}
- umask(0);
+ umask(S_IRWXG | S_IRWXO);
sid = setsid();
if (sid < 0) {
goto fail;
|
CWE-264
| null | null |
3,053
|
svc_dg_enable_pktinfo(int fd, const struct __rpc_sockinfo *si)
{
int val = 1;
switch (si->si_af) {
case AF_INET:
(void) setsockopt(fd, SOL_IP, IP_PKTINFO, &val, sizeof(val));
break;
#ifdef INET6
case AF_INET6:
(void) setsockopt(fd, SOL_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val));
break;
#endif
}
}
|
DoS
| 0
|
svc_dg_enable_pktinfo(int fd, const struct __rpc_sockinfo *si)
{
int val = 1;
switch (si->si_af) {
case AF_INET:
(void) setsockopt(fd, SOL_IP, IP_PKTINFO, &val, sizeof(val));
break;
#ifdef INET6
case AF_INET6:
(void) setsockopt(fd, SOL_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val));
break;
#endif
}
}
|
@@ -284,7 +284,6 @@ svc_dg_getargs(xprt, xdr_args, args_ptr)
{
if (! SVCAUTH_UNWRAP(xprt->xp_auth, &(su_data(xprt)->su_xdrs),
xdr_args, args_ptr)) {
- (void)svc_freeargs(xprt, xdr_args, args_ptr);
return FALSE;
}
return TRUE;
|
CWE-399
| null | null |
3,054
|
svc_dg_valid_pktinfo(struct msghdr *msg)
{
struct cmsghdr *cmsg;
if (!msg->msg_name)
return 0;
if (msg->msg_flags & MSG_CTRUNC)
return 0;
cmsg = CMSG_FIRSTHDR(msg);
if (cmsg == NULL || CMSG_NXTHDR(msg, cmsg) != NULL)
return 0;
switch (((struct sockaddr *) msg->msg_name)->sa_family) {
case AF_INET:
if (cmsg->cmsg_level != SOL_IP
|| cmsg->cmsg_type != IP_PKTINFO
|| cmsg->cmsg_len < CMSG_LEN(sizeof (struct in_pktinfo))) {
return 0;
} else {
struct in_pktinfo *pkti;
pkti = (struct in_pktinfo *) CMSG_DATA (cmsg);
pkti->ipi_ifindex = 0;
}
break;
#ifdef INET6
case AF_INET6:
if (cmsg->cmsg_level != SOL_IPV6
|| cmsg->cmsg_type != IPV6_PKTINFO
|| cmsg->cmsg_len < CMSG_LEN(sizeof (struct in6_pktinfo))) {
return 0;
} else {
struct in6_pktinfo *pkti;
pkti = (struct in6_pktinfo *) CMSG_DATA (cmsg);
pkti->ipi6_ifindex = 0;
}
break;
#endif
default:
return 0;
}
return 1;
}
|
DoS
| 0
|
svc_dg_valid_pktinfo(struct msghdr *msg)
{
struct cmsghdr *cmsg;
if (!msg->msg_name)
return 0;
if (msg->msg_flags & MSG_CTRUNC)
return 0;
cmsg = CMSG_FIRSTHDR(msg);
if (cmsg == NULL || CMSG_NXTHDR(msg, cmsg) != NULL)
return 0;
switch (((struct sockaddr *) msg->msg_name)->sa_family) {
case AF_INET:
if (cmsg->cmsg_level != SOL_IP
|| cmsg->cmsg_type != IP_PKTINFO
|| cmsg->cmsg_len < CMSG_LEN(sizeof (struct in_pktinfo))) {
return 0;
} else {
struct in_pktinfo *pkti;
pkti = (struct in_pktinfo *) CMSG_DATA (cmsg);
pkti->ipi_ifindex = 0;
}
break;
#ifdef INET6
case AF_INET6:
if (cmsg->cmsg_level != SOL_IPV6
|| cmsg->cmsg_type != IPV6_PKTINFO
|| cmsg->cmsg_len < CMSG_LEN(sizeof (struct in6_pktinfo))) {
return 0;
} else {
struct in6_pktinfo *pkti;
pkti = (struct in6_pktinfo *) CMSG_DATA (cmsg);
pkti->ipi6_ifindex = 0;
}
break;
#endif
default:
return 0;
}
return 1;
}
|
@@ -284,7 +284,6 @@ svc_dg_getargs(xprt, xdr_args, args_ptr)
{
if (! SVCAUTH_UNWRAP(xprt->xp_auth, &(su_data(xprt)->su_xdrs),
xdr_args, args_ptr)) {
- (void)svc_freeargs(xprt, xdr_args, args_ptr);
return FALSE;
}
return TRUE;
|
CWE-399
| null | null |
3,055
|
xmlNsPtr attr_find_ns(xmlAttrPtr node)
{
if (node->ns) {
return node->ns;
} else if (node->parent->ns) {
return node->parent->ns;
} else {
return xmlSearchNs(node->doc, node->parent, NULL);
}
}
|
+Info
| 0
|
xmlNsPtr attr_find_ns(xmlAttrPtr node)
{
if (node->ns) {
return node->ns;
} else if (node->parent->ns) {
return node->parent->ns;
} else {
return xmlSearchNs(node->doc, node->parent, NULL);
}
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,056
|
static void cleanup_xml_node(xmlNodePtr node)
{
xmlNodePtr trav;
xmlNodePtr del = NULL;
trav = node->children;
while (trav != NULL) {
if (del != NULL) {
xmlUnlinkNode(del);
xmlFreeNode(del);
del = NULL;
}
if (trav->type == XML_TEXT_NODE) {
if (is_blank(trav->content)) {
del = trav;
}
} else if ((trav->type != XML_ELEMENT_NODE) &&
(trav->type != XML_CDATA_SECTION_NODE)) {
del = trav;
} else if (trav->children != NULL) {
cleanup_xml_node(trav);
}
trav = trav->next;
}
if (del != NULL) {
xmlUnlinkNode(del);
xmlFreeNode(del);
}
}
|
+Info
| 0
|
static void cleanup_xml_node(xmlNodePtr node)
{
xmlNodePtr trav;
xmlNodePtr del = NULL;
trav = node->children;
while (trav != NULL) {
if (del != NULL) {
xmlUnlinkNode(del);
xmlFreeNode(del);
del = NULL;
}
if (trav->type == XML_TEXT_NODE) {
if (is_blank(trav->content)) {
del = trav;
}
} else if ((trav->type != XML_ELEMENT_NODE) &&
(trav->type != XML_CDATA_SECTION_NODE)) {
del = trav;
} else if (trav->children != NULL) {
cleanup_xml_node(trav);
}
trav = trav->next;
}
if (del != NULL) {
xmlUnlinkNode(del);
xmlFreeNode(del);
}
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,057
|
xmlNodePtr get_node_ex(xmlNodePtr node, char *name, char *ns)
{
while (node!=NULL) {
if (node_is_equal_ex(node, name, ns)) {
return node;
}
node = node->next;
}
return NULL;
}
|
+Info
| 0
|
xmlNodePtr get_node_ex(xmlNodePtr node, char *name, char *ns)
{
while (node!=NULL) {
if (node_is_equal_ex(node, name, ns)) {
return node;
}
node = node->next;
}
return NULL;
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,058
|
xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, char *name, char *ns)
{
while (node != NULL) {
if (node_is_equal_ex(node, name, ns)) {
return node;
} else if (node->children != NULL) {
xmlNodePtr tmp = get_node_recurisve_ex(node->children, name, ns);
if (tmp) {
return tmp;
}
}
node = node->next;
}
return NULL;
}
|
+Info
| 0
|
xmlNodePtr get_node_recurisve_ex(xmlNodePtr node, char *name, char *ns)
{
while (node != NULL) {
if (node_is_equal_ex(node, name, ns)) {
return node;
} else if (node->children != NULL) {
xmlNodePtr tmp = get_node_recurisve_ex(node->children, name, ns);
if (tmp) {
return tmp;
}
}
node = node->next;
}
return NULL;
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,059
|
xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns)
{
xmlAttrPtr attr;
while (node != NULL) {
if (name != NULL) {
node = get_node_ex(node, name, name_ns);
if (node==NULL) {
return NULL;
}
}
attr = get_attribute_ex(node->properties, attribute, attr_ns);
if (attr != NULL && strcmp((char*)attr->children->content, value) == 0) {
return node;
}
node = node->next;
}
return NULL;
}
|
+Info
| 0
|
xmlNodePtr get_node_with_attribute_ex(xmlNodePtr node, char *name, char *name_ns, char *attribute, char *value, char *attr_ns)
{
xmlAttrPtr attr;
while (node != NULL) {
if (name != NULL) {
node = get_node_ex(node, name, name_ns);
if (node==NULL) {
return NULL;
}
}
attr = get_attribute_ex(node->properties, attribute, attr_ns);
if (attr != NULL && strcmp((char*)attr->children->content, value) == 0) {
return node;
}
node = node->next;
}
return NULL;
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,060
|
static int is_blank(const xmlChar* str)
{
while (*str != '\0') {
if (*str != ' ' && *str != 0x9 && *str != 0xa && *str != 0xd) {
return 0;
}
str++;
}
return 1;
}
|
+Info
| 0
|
static int is_blank(const xmlChar* str)
{
while (*str != '\0') {
if (*str != ' ' && *str != 0x9 && *str != 0xa && *str != 0xd) {
return 0;
}
str++;
}
return 1;
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,061
|
int node_is_equal_ex(xmlNodePtr node, char *name, char *ns)
{
if (name == NULL || strcmp((char*)node->name, name) == 0) {
if (ns) {
xmlNsPtr nsPtr = node_find_ns(node);
if (nsPtr) {
return (strcmp((char*)nsPtr->href, ns) == 0);
} else {
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
|
+Info
| 0
|
int node_is_equal_ex(xmlNodePtr node, char *name, char *ns)
{
if (name == NULL || strcmp((char*)node->name, name) == 0) {
if (ns) {
xmlNsPtr nsPtr = node_find_ns(node);
if (nsPtr) {
return (strcmp((char*)nsPtr->href, ns) == 0);
} else {
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,062
|
int parse_namespace(const xmlChar *inval, char **value, char **namespace)
{
char *found = strrchr((char*)inval, ':');
if (found != NULL && found != (char*)inval) {
(*namespace) = estrndup((char*)inval, found - (char*)inval);
(*value) = estrdup(++found);
} else {
(*value) = estrdup((char*)inval);
(*namespace) = NULL;
}
return FALSE;
}
|
+Info
| 0
|
int parse_namespace(const xmlChar *inval, char **value, char **namespace)
{
char *found = strrchr((char*)inval, ':');
if (found != NULL && found != (char*)inval) {
(*namespace) = estrndup((char*)inval, found - (char*)inval);
(*value) = estrdup(++found);
} else {
(*value) = estrdup((char*)inval);
(*namespace) = NULL;
}
return FALSE;
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,063
|
int php_stream_xmlIO_match_wrapper(const char *filename)
{
TSRMLS_FETCH();
return php_stream_locate_url_wrapper(filename, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) ? 1 : 0;
}
|
+Info
| 0
|
int php_stream_xmlIO_match_wrapper(const char *filename)
{
TSRMLS_FETCH();
return php_stream_locate_url_wrapper(filename, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC) ? 1 : 0;
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,064
|
void *php_stream_xmlIO_open_wrapper(const char *filename)
{
TSRMLS_FETCH();
return php_stream_open_wrapper((char*)filename, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
}
|
+Info
| 0
|
void *php_stream_xmlIO_open_wrapper(const char *filename)
{
TSRMLS_FETCH();
return php_stream_open_wrapper((char*)filename, "rb", ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,065
|
static void soap_Comment(void *ctx, const xmlChar *value)
{
}
|
+Info
| 0
|
static void soap_Comment(void *ctx, const xmlChar *value)
{
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,066
|
static void soap_ignorableWhitespace(void *ctx, const xmlChar *ch, int len)
{
}
|
+Info
| 0
|
static void soap_ignorableWhitespace(void *ctx, const xmlChar *ch, int len)
{
}
|
@@ -92,7 +92,7 @@ xmlDocPtr soap_xmlParseFile(const char *filename TSRMLS_DC)
PG(allow_url_fopen) = old_allow_url_fopen;
if (ctxt) {
ctxt->keepBlanks = 0;
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
@@ -134,7 +134,7 @@ xmlDocPtr soap_xmlParseMemory(const void *buf, size_t buf_size)
*/
ctxt = xmlCreateMemoryParserCtxt(buf, buf_size);
if (ctxt) {
- ctxt->options -= XML_PARSE_DTDLOAD;
+ ctxt->options &= ~XML_PARSE_DTDLOAD;
ctxt->sax->ignorableWhitespace = soap_ignorableWhitespace;
ctxt->sax->comment = soap_Comment;
ctxt->sax->warning = NULL;
|
CWE-200
| null | null |
3,067
|
static void make_default_cur_rule(void)
{
memset(&G.cur_rule, 0, sizeof(G.cur_rule));
G.cur_rule.maj = -1; /* "not a @major,minor rule" */
G.cur_rule.mode = 0660;
}
| null | 0
|
static void make_default_cur_rule(void)
{
memset(&G.cur_rule, 0, sizeof(G.cur_rule));
G.cur_rule.maj = -1; /* "not a @major,minor rule" */
G.cur_rule.mode = 0660;
}
|
@@ -429,6 +429,18 @@ static const struct rule *next_rule(void)
#endif
+static void mkdir_recursive(char *name)
+{
+ /* if name has many levels ("dir1/dir2"),
+ * bb_make_directory() will create dir1 according to umask,
+ * not according to its "mode" parameter.
+ * Since we run with umask=0, need to temporarily switch it.
+ */
+ umask(022); /* "dir1" (if any) will be 0755 too */
+ bb_make_directory(name, 0755, FILEUTILS_RECUR);
+ umask(0);
+}
+
/* Builds an alias path.
* This function potentionally reallocates the alias parameter.
* Only used for ENABLE_FEATURE_MDEV_RENAME
@@ -442,7 +454,7 @@ static char *build_alias(char *alias, const char *device_name)
dest = strrchr(alias, '/');
if (dest) { /* ">bar/[baz]" ? */
*dest = '\0'; /* mkdir bar */
- bb_make_directory(alias, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(alias);
*dest = '/';
if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
dest = alias;
@@ -641,7 +653,7 @@ static void make_device(char *device_name, char *path, int operation)
char *slash = strrchr(node_name, '/');
if (slash) {
*slash = '\0';
- bb_make_directory(node_name, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(node_name);
*slash = '/';
}
if (G.verbose)
|
CWE-264
| null | null |
3,068
|
static const struct rule *next_rule(void)
{
struct rule *rule;
/* Open conf file if we didn't do it yet */
if (!G.parser && G.filename) {
dbg("config_open('%s')", G.filename);
G.parser = config_open2(G.filename, fopen_for_read);
G.filename = NULL;
}
if (G.rule_vec) {
/* mdev -s */
/* Do we have rule parsed already? */
if (G.rule_vec[G.rule_idx]) {
dbg("< G.rule_vec[G.rule_idx:%d]=%p", G.rule_idx, G.rule_vec[G.rule_idx]);
return G.rule_vec[G.rule_idx++];
}
make_default_cur_rule();
} else {
/* not mdev -s */
clean_up_cur_rule();
}
/* Parse one more rule if file isn't fully read */
rule = &G.cur_rule;
if (G.parser) {
parse_next_rule();
if (G.rule_vec) { /* mdev -s */
rule = memcpy(xmalloc(sizeof(G.cur_rule)), &G.cur_rule, sizeof(G.cur_rule));
G.rule_vec = xrealloc_vector(G.rule_vec, 4, G.rule_idx);
G.rule_vec[G.rule_idx++] = rule;
dbg("> G.rule_vec[G.rule_idx:%d]=%p", G.rule_idx, G.rule_vec[G.rule_idx]);
}
}
return rule;
}
| null | 0
|
static const struct rule *next_rule(void)
{
struct rule *rule;
/* Open conf file if we didn't do it yet */
if (!G.parser && G.filename) {
dbg("config_open('%s')", G.filename);
G.parser = config_open2(G.filename, fopen_for_read);
G.filename = NULL;
}
if (G.rule_vec) {
/* mdev -s */
/* Do we have rule parsed already? */
if (G.rule_vec[G.rule_idx]) {
dbg("< G.rule_vec[G.rule_idx:%d]=%p", G.rule_idx, G.rule_vec[G.rule_idx]);
return G.rule_vec[G.rule_idx++];
}
make_default_cur_rule();
} else {
/* not mdev -s */
clean_up_cur_rule();
}
/* Parse one more rule if file isn't fully read */
rule = &G.cur_rule;
if (G.parser) {
parse_next_rule();
if (G.rule_vec) { /* mdev -s */
rule = memcpy(xmalloc(sizeof(G.cur_rule)), &G.cur_rule, sizeof(G.cur_rule));
G.rule_vec = xrealloc_vector(G.rule_vec, 4, G.rule_idx);
G.rule_vec[G.rule_idx++] = rule;
dbg("> G.rule_vec[G.rule_idx:%d]=%p", G.rule_idx, G.rule_vec[G.rule_idx]);
}
}
return rule;
}
|
@@ -429,6 +429,18 @@ static const struct rule *next_rule(void)
#endif
+static void mkdir_recursive(char *name)
+{
+ /* if name has many levels ("dir1/dir2"),
+ * bb_make_directory() will create dir1 according to umask,
+ * not according to its "mode" parameter.
+ * Since we run with umask=0, need to temporarily switch it.
+ */
+ umask(022); /* "dir1" (if any) will be 0755 too */
+ bb_make_directory(name, 0755, FILEUTILS_RECUR);
+ umask(0);
+}
+
/* Builds an alias path.
* This function potentionally reallocates the alias parameter.
* Only used for ENABLE_FEATURE_MDEV_RENAME
@@ -442,7 +454,7 @@ static char *build_alias(char *alias, const char *device_name)
dest = strrchr(alias, '/');
if (dest) { /* ">bar/[baz]" ? */
*dest = '\0'; /* mkdir bar */
- bb_make_directory(alias, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(alias);
*dest = '/';
if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
dest = alias;
@@ -641,7 +653,7 @@ static void make_device(char *device_name, char *path, int operation)
char *slash = strrchr(node_name, '/');
if (slash) {
*slash = '\0';
- bb_make_directory(node_name, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(node_name);
*slash = '/';
}
if (G.verbose)
|
CWE-264
| null | null |
3,069
|
static void parse_next_rule(void)
{
/* Note: on entry, G.cur_rule is set to default */
while (1) {
char *tokens[4];
char *val;
/* No PARSE_EOL_COMMENTS, because command may contain '#' chars */
if (!config_read(G.parser, tokens, 4, 3, "# \t", PARSE_NORMAL & ~PARSE_EOL_COMMENTS))
break;
/* Fields: [-]regex uid:gid mode [alias] [cmd] */
dbg("token1:'%s'", tokens[1]);
/* 1st field */
val = tokens[0];
G.cur_rule.keep_matching = ('-' == val[0]);
val += G.cur_rule.keep_matching; /* swallow leading dash */
if (val[0] == '@') {
/* @major,minor[-minor2] */
/* (useful when name is ambiguous:
* "/sys/class/usb/lp0" and
* "/sys/class/printer/lp0")
*/
int sc = sscanf(val, "@%u,%u-%u", &G.cur_rule.maj, &G.cur_rule.min0, &G.cur_rule.min1);
if (sc < 2 || G.cur_rule.maj < 0) {
bb_error_msg("bad @maj,min on line %d", G.parser->lineno);
goto next_rule;
}
if (sc == 2)
G.cur_rule.min1 = G.cur_rule.min0;
} else {
if (val[0] == '$') {
char *eq = strchr(++val, '=');
if (!eq) {
bb_error_msg("bad $envvar=regex on line %d", G.parser->lineno);
goto next_rule;
}
G.cur_rule.envvar = xstrndup(val, eq - val);
val = eq + 1;
}
xregcomp(&G.cur_rule.match, val, REG_EXTENDED);
G.cur_rule.regex_compiled = 1;
}
/* 2nd field: uid:gid - device ownership */
if (get_uidgid(&G.cur_rule.ugid, tokens[1], /*allow_numeric:*/ 1) == 0) {
bb_error_msg("unknown user/group '%s' on line %d", tokens[1], G.parser->lineno);
goto next_rule;
}
/* 3rd field: mode - device permissions */
bb_parse_mode(tokens[2], &G.cur_rule.mode);
/* 4th field (opt): ">|=alias" or "!" to not create the node */
val = tokens[3];
if (ENABLE_FEATURE_MDEV_RENAME && val && strchr(">=!", val[0])) {
char *s = skip_non_whitespace(val);
G.cur_rule.ren_mov = xstrndup(val, s - val);
val = skip_whitespace(s);
}
if (ENABLE_FEATURE_MDEV_EXEC && val && val[0]) {
const char *s = "$@*";
const char *s2 = strchr(s, val[0]);
if (!s2) {
bb_error_msg("bad line %u", G.parser->lineno);
goto next_rule;
}
IF_FEATURE_MDEV_EXEC(G.cur_rule.r_cmd = xstrdup(val);)
}
return;
next_rule:
clean_up_cur_rule();
} /* while (config_read) */
dbg("config_close(G.parser)");
config_close(G.parser);
G.parser = NULL;
return;
}
| null | 0
|
static void parse_next_rule(void)
{
/* Note: on entry, G.cur_rule is set to default */
while (1) {
char *tokens[4];
char *val;
/* No PARSE_EOL_COMMENTS, because command may contain '#' chars */
if (!config_read(G.parser, tokens, 4, 3, "# \t", PARSE_NORMAL & ~PARSE_EOL_COMMENTS))
break;
/* Fields: [-]regex uid:gid mode [alias] [cmd] */
dbg("token1:'%s'", tokens[1]);
/* 1st field */
val = tokens[0];
G.cur_rule.keep_matching = ('-' == val[0]);
val += G.cur_rule.keep_matching; /* swallow leading dash */
if (val[0] == '@') {
/* @major,minor[-minor2] */
/* (useful when name is ambiguous:
* "/sys/class/usb/lp0" and
* "/sys/class/printer/lp0")
*/
int sc = sscanf(val, "@%u,%u-%u", &G.cur_rule.maj, &G.cur_rule.min0, &G.cur_rule.min1);
if (sc < 2 || G.cur_rule.maj < 0) {
bb_error_msg("bad @maj,min on line %d", G.parser->lineno);
goto next_rule;
}
if (sc == 2)
G.cur_rule.min1 = G.cur_rule.min0;
} else {
if (val[0] == '$') {
char *eq = strchr(++val, '=');
if (!eq) {
bb_error_msg("bad $envvar=regex on line %d", G.parser->lineno);
goto next_rule;
}
G.cur_rule.envvar = xstrndup(val, eq - val);
val = eq + 1;
}
xregcomp(&G.cur_rule.match, val, REG_EXTENDED);
G.cur_rule.regex_compiled = 1;
}
/* 2nd field: uid:gid - device ownership */
if (get_uidgid(&G.cur_rule.ugid, tokens[1], /*allow_numeric:*/ 1) == 0) {
bb_error_msg("unknown user/group '%s' on line %d", tokens[1], G.parser->lineno);
goto next_rule;
}
/* 3rd field: mode - device permissions */
bb_parse_mode(tokens[2], &G.cur_rule.mode);
/* 4th field (opt): ">|=alias" or "!" to not create the node */
val = tokens[3];
if (ENABLE_FEATURE_MDEV_RENAME && val && strchr(">=!", val[0])) {
char *s = skip_non_whitespace(val);
G.cur_rule.ren_mov = xstrndup(val, s - val);
val = skip_whitespace(s);
}
if (ENABLE_FEATURE_MDEV_EXEC && val && val[0]) {
const char *s = "$@*";
const char *s2 = strchr(s, val[0]);
if (!s2) {
bb_error_msg("bad line %u", G.parser->lineno);
goto next_rule;
}
IF_FEATURE_MDEV_EXEC(G.cur_rule.r_cmd = xstrdup(val);)
}
return;
next_rule:
clean_up_cur_rule();
} /* while (config_read) */
dbg("config_close(G.parser)");
config_close(G.parser);
G.parser = NULL;
return;
}
|
@@ -429,6 +429,18 @@ static const struct rule *next_rule(void)
#endif
+static void mkdir_recursive(char *name)
+{
+ /* if name has many levels ("dir1/dir2"),
+ * bb_make_directory() will create dir1 according to umask,
+ * not according to its "mode" parameter.
+ * Since we run with umask=0, need to temporarily switch it.
+ */
+ umask(022); /* "dir1" (if any) will be 0755 too */
+ bb_make_directory(name, 0755, FILEUTILS_RECUR);
+ umask(0);
+}
+
/* Builds an alias path.
* This function potentionally reallocates the alias parameter.
* Only used for ENABLE_FEATURE_MDEV_RENAME
@@ -442,7 +454,7 @@ static char *build_alias(char *alias, const char *device_name)
dest = strrchr(alias, '/');
if (dest) { /* ">bar/[baz]" ? */
*dest = '\0'; /* mkdir bar */
- bb_make_directory(alias, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(alias);
*dest = '/';
if (dest[1] == '\0') { /* ">bar/" => ">bar/device_name" */
dest = alias;
@@ -641,7 +653,7 @@ static void make_device(char *device_name, char *path, int operation)
char *slash = strrchr(node_name, '/');
if (slash) {
*slash = '\0';
- bb_make_directory(node_name, 0755, FILEUTILS_RECUR);
+ mkdir_recursive(node_name);
*slash = '/';
}
if (G.verbose)
|
CWE-264
| null | null |
3,070
|
_asn1_add_static_node (unsigned int type)
{
list_type *listElement;
asn1_node punt;
punt = calloc (1, sizeof (struct asn1_node_st));
if (punt == NULL)
return NULL;
listElement = malloc (sizeof (list_type));
if (listElement == NULL)
{
free (punt);
return NULL;
}
listElement->node = punt;
listElement->next = firstElement;
firstElement = listElement;
punt->type = type;
return punt;
}
|
Overflow
| 0
|
_asn1_add_static_node (unsigned int type)
{
list_type *listElement;
asn1_node punt;
punt = calloc (1, sizeof (struct asn1_node_st));
if (punt == NULL)
return NULL;
listElement = malloc (sizeof (list_type));
if (listElement == NULL)
{
free (punt);
return NULL;
}
listElement->node = punt;
listElement->next = firstElement;
firstElement = listElement;
punt->type = type;
return punt;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,071
|
_asn1_change_integer_value (asn1_node node)
{
asn1_node p;
unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];
int len;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if ((type_field (p->type) == ASN1_ETYPE_INTEGER)
&& (p->type & CONST_ASSIGN))
{
if (p->value)
{
_asn1_convert_integer (p->value, val, sizeof (val), &len);
asn1_octet_der (val, len, val2, &len);
_asn1_set_value (p, val2, len);
}
}
if (p->down)
{
p = p->down;
}
else
{
if (p == node)
p = NULL;
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_get_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
}
return ASN1_SUCCESS;
}
|
Overflow
| 0
|
_asn1_change_integer_value (asn1_node node)
{
asn1_node p;
unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];
int len;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if ((type_field (p->type) == ASN1_ETYPE_INTEGER)
&& (p->type & CONST_ASSIGN))
{
if (p->value)
{
_asn1_convert_integer (p->value, val, sizeof (val), &len);
asn1_octet_der (val, len, val2, &len);
_asn1_set_value (p, val2, len);
}
}
if (p->down)
{
p = p->down;
}
else
{
if (p == node)
p = NULL;
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_get_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
}
return ASN1_SUCCESS;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,072
|
_asn1_check_identifier (asn1_node node)
{
asn1_node p, p2;
char name2[ASN1_MAX_NAME_SIZE * 2 + 2];
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if (p->value && type_field (p->type) == ASN1_ETYPE_IDENTIFIER)
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p->value);
p2 = asn1_find_node (node, name2);
if (p2 == NULL)
{
if (p->value)
_asn1_strcpy (_asn1_identifierMissing, p->value);
else
_asn1_strcpy (_asn1_identifierMissing, "(null)");
return ASN1_IDENTIFIER_NOT_FOUND;
}
}
else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
(p->type & CONST_DEFAULT))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
_asn1_strcpy (_asn1_identifierMissing, p2->value);
p2 = asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID) ||
!(p2->type & CONST_ASSIGN))
return ASN1_IDENTIFIER_NOT_FOUND;
else
_asn1_identifierMissing[0] = 0;
}
}
else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
(p->type & CONST_ASSIGN))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))
{
if (p2->value && !isdigit (p2->value[0]))
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
_asn1_strcpy (_asn1_identifierMissing, p2->value);
p2 = asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID)
|| !(p2->type & CONST_ASSIGN))
return ASN1_IDENTIFIER_NOT_FOUND;
else
_asn1_identifierMissing[0] = 0;
}
}
}
if (p->down)
{
p = p->down;
}
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_get_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
return ASN1_SUCCESS;
}
|
Overflow
| 0
|
_asn1_check_identifier (asn1_node node)
{
asn1_node p, p2;
char name2[ASN1_MAX_NAME_SIZE * 2 + 2];
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if (p->value && type_field (p->type) == ASN1_ETYPE_IDENTIFIER)
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p->value);
p2 = asn1_find_node (node, name2);
if (p2 == NULL)
{
if (p->value)
_asn1_strcpy (_asn1_identifierMissing, p->value);
else
_asn1_strcpy (_asn1_identifierMissing, "(null)");
return ASN1_IDENTIFIER_NOT_FOUND;
}
}
else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
(p->type & CONST_DEFAULT))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
_asn1_strcpy (_asn1_identifierMissing, p2->value);
p2 = asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID) ||
!(p2->type & CONST_ASSIGN))
return ASN1_IDENTIFIER_NOT_FOUND;
else
_asn1_identifierMissing[0] = 0;
}
}
else if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
(p->type & CONST_ASSIGN))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))
{
if (p2->value && !isdigit (p2->value[0]))
{
_asn1_str_cpy (name2, sizeof (name2), node->name);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
_asn1_strcpy (_asn1_identifierMissing, p2->value);
p2 = asn1_find_node (node, name2);
if (!p2 || (type_field (p2->type) != ASN1_ETYPE_OBJECT_ID)
|| !(p2->type & CONST_ASSIGN))
return ASN1_IDENTIFIER_NOT_FOUND;
else
_asn1_identifierMissing[0] = 0;
}
}
}
if (p->down)
{
p = p->down;
}
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_get_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
return ASN1_SUCCESS;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,073
|
_asn1_cpy_name (asn1_node dst, asn1_node src)
{
if (dst == NULL)
return dst;
if (src == NULL)
{
dst->name[0] = 0;
dst->name_hash = hash_pjw_bare (dst->name, 0);
return dst;
}
_asn1_str_cpy (dst->name, sizeof (dst->name), src->name);
dst->name_hash = src->name_hash;
return dst;
}
|
Overflow
| 0
|
_asn1_cpy_name (asn1_node dst, asn1_node src)
{
if (dst == NULL)
return dst;
if (src == NULL)
{
dst->name[0] = 0;
dst->name_hash = hash_pjw_bare (dst->name, 0);
return dst;
}
_asn1_str_cpy (dst->name, sizeof (dst->name), src->name);
dst->name_hash = src->name_hash;
return dst;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,074
|
_asn1_delete_list (void)
{
list_type *listElement;
while (firstElement)
{
listElement = firstElement;
firstElement = firstElement->next;
free (listElement);
}
}
|
Overflow
| 0
|
_asn1_delete_list (void)
{
list_type *listElement;
while (firstElement)
{
listElement = firstElement;
firstElement = firstElement->next;
free (listElement);
}
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,075
|
_asn1_delete_list_and_nodes (void)
{
list_type *listElement;
while (firstElement)
{
listElement = firstElement;
firstElement = firstElement->next;
_asn1_remove_node (listElement->node, 0);
free (listElement);
}
}
|
Overflow
| 0
|
_asn1_delete_list_and_nodes (void)
{
list_type *listElement;
while (firstElement)
{
listElement = firstElement;
firstElement = firstElement->next;
_asn1_remove_node (listElement->node, 0);
free (listElement);
}
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,076
|
_asn1_expand_object_id (asn1_node node)
{
asn1_node p, p2, p3, p4, p5;
char name_root[ASN1_MAX_NAME_SIZE], name2[2 * ASN1_MAX_NAME_SIZE + 1];
int move, tlen;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
_asn1_str_cpy (name_root, sizeof (name_root), node->name);
p = node;
move = DOWN;
while (!((p == node) && (move == UP)))
{
if (move != UP)
{
if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID)
&& (p->type & CONST_ASSIGN))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))
{
if (p2->value && !isdigit (p2->value[0]))
{
_asn1_str_cpy (name2, sizeof (name2), name_root);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2),
(char *) p2->value);
p3 = asn1_find_node (node, name2);
if (!p3
|| (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID)
|| !(p3->type & CONST_ASSIGN))
return ASN1_ELEMENT_NOT_FOUND;
_asn1_set_down (p, p2->right);
_asn1_remove_node (p2, 0);
p2 = p;
p4 = p3->down;
while (p4)
{
if (type_field (p4->type) == ASN1_ETYPE_CONSTANT)
{
p5 =
_asn1_add_single_node (ASN1_ETYPE_CONSTANT);
_asn1_set_name (p5, p4->name);
if (p4->value)
{
tlen = _asn1_strlen (p4->value);
if (tlen > 0)
_asn1_set_value (p5, p4->value, tlen + 1);
}
if (p2 == p)
{
_asn1_set_right (p5, p->down);
_asn1_set_down (p, p5);
}
else
{
_asn1_set_right (p5, p2->right);
_asn1_set_right (p2, p5);
}
p2 = p5;
}
p4 = p4->right;
}
move = DOWN;
continue;
}
}
}
move = DOWN;
}
else
move = RIGHT;
if (move == DOWN)
{
if (p->down)
p = p->down;
else
move = RIGHT;
}
if (p == node)
{
move = UP;
continue;
}
if (move == RIGHT)
{
if (p->right)
p = p->right;
else
move = UP;
}
if (move == UP)
p = _asn1_get_up (p);
}
/*******************************/
/* expand DEFAULT */
/*******************************/
p = node;
move = DOWN;
while (!((p == node) && (move == UP)))
{
if (move != UP)
{
if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
(p->type & CONST_DEFAULT))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))
{
_asn1_str_cpy (name2, sizeof (name2), name_root);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
p3 = asn1_find_node (node, name2);
if (!p3 || (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID)
|| !(p3->type & CONST_ASSIGN))
return ASN1_ELEMENT_NOT_FOUND;
p4 = p3->down;
name2[0] = 0;
while (p4)
{
if (type_field (p4->type) == ASN1_ETYPE_CONSTANT)
{
if (name2[0])
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2),
(char *) p4->value);
}
p4 = p4->right;
}
tlen = strlen (name2);
if (tlen > 0)
_asn1_set_value (p2, name2, tlen + 1);
}
}
move = DOWN;
}
else
move = RIGHT;
if (move == DOWN)
{
if (p->down)
p = p->down;
else
move = RIGHT;
}
if (p == node)
{
move = UP;
continue;
}
if (move == RIGHT)
{
if (p->right)
p = p->right;
else
move = UP;
}
if (move == UP)
p = _asn1_get_up (p);
}
return ASN1_SUCCESS;
}
|
Overflow
| 0
|
_asn1_expand_object_id (asn1_node node)
{
asn1_node p, p2, p3, p4, p5;
char name_root[ASN1_MAX_NAME_SIZE], name2[2 * ASN1_MAX_NAME_SIZE + 1];
int move, tlen;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
_asn1_str_cpy (name_root, sizeof (name_root), node->name);
p = node;
move = DOWN;
while (!((p == node) && (move == UP)))
{
if (move != UP)
{
if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID)
&& (p->type & CONST_ASSIGN))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_CONSTANT))
{
if (p2->value && !isdigit (p2->value[0]))
{
_asn1_str_cpy (name2, sizeof (name2), name_root);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2),
(char *) p2->value);
p3 = asn1_find_node (node, name2);
if (!p3
|| (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID)
|| !(p3->type & CONST_ASSIGN))
return ASN1_ELEMENT_NOT_FOUND;
_asn1_set_down (p, p2->right);
_asn1_remove_node (p2, 0);
p2 = p;
p4 = p3->down;
while (p4)
{
if (type_field (p4->type) == ASN1_ETYPE_CONSTANT)
{
p5 =
_asn1_add_single_node (ASN1_ETYPE_CONSTANT);
_asn1_set_name (p5, p4->name);
if (p4->value)
{
tlen = _asn1_strlen (p4->value);
if (tlen > 0)
_asn1_set_value (p5, p4->value, tlen + 1);
}
if (p2 == p)
{
_asn1_set_right (p5, p->down);
_asn1_set_down (p, p5);
}
else
{
_asn1_set_right (p5, p2->right);
_asn1_set_right (p2, p5);
}
p2 = p5;
}
p4 = p4->right;
}
move = DOWN;
continue;
}
}
}
move = DOWN;
}
else
move = RIGHT;
if (move == DOWN)
{
if (p->down)
p = p->down;
else
move = RIGHT;
}
if (p == node)
{
move = UP;
continue;
}
if (move == RIGHT)
{
if (p->right)
p = p->right;
else
move = UP;
}
if (move == UP)
p = _asn1_get_up (p);
}
/*******************************/
/* expand DEFAULT */
/*******************************/
p = node;
move = DOWN;
while (!((p == node) && (move == UP)))
{
if (move != UP)
{
if ((type_field (p->type) == ASN1_ETYPE_OBJECT_ID) &&
(p->type & CONST_DEFAULT))
{
p2 = p->down;
if (p2 && (type_field (p2->type) == ASN1_ETYPE_DEFAULT))
{
_asn1_str_cpy (name2, sizeof (name2), name_root);
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2), (char *) p2->value);
p3 = asn1_find_node (node, name2);
if (!p3 || (type_field (p3->type) != ASN1_ETYPE_OBJECT_ID)
|| !(p3->type & CONST_ASSIGN))
return ASN1_ELEMENT_NOT_FOUND;
p4 = p3->down;
name2[0] = 0;
while (p4)
{
if (type_field (p4->type) == ASN1_ETYPE_CONSTANT)
{
if (name2[0])
_asn1_str_cat (name2, sizeof (name2), ".");
_asn1_str_cat (name2, sizeof (name2),
(char *) p4->value);
}
p4 = p4->right;
}
tlen = strlen (name2);
if (tlen > 0)
_asn1_set_value (p2, name2, tlen + 1);
}
}
move = DOWN;
}
else
move = RIGHT;
if (move == DOWN)
{
if (p->down)
p = p->down;
else
move = RIGHT;
}
if (p == node)
{
move = UP;
continue;
}
if (move == RIGHT)
{
if (p->right)
p = p->right;
else
move = UP;
}
if (move == UP)
p = _asn1_get_up (p);
}
return ASN1_SUCCESS;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,077
|
_asn1_set_default_tag (asn1_node node)
{
asn1_node p;
if ((node == NULL) || (type_field (node->type) != ASN1_ETYPE_DEFINITIONS))
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if ((type_field (p->type) == ASN1_ETYPE_TAG) &&
!(p->type & CONST_EXPLICIT) && !(p->type & CONST_IMPLICIT))
{
if (node->type & CONST_EXPLICIT)
p->type |= CONST_EXPLICIT;
else
p->type |= CONST_IMPLICIT;
}
if (p->down)
{
p = p->down;
}
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_get_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
return ASN1_SUCCESS;
}
|
Overflow
| 0
|
_asn1_set_default_tag (asn1_node node)
{
asn1_node p;
if ((node == NULL) || (type_field (node->type) != ASN1_ETYPE_DEFINITIONS))
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if ((type_field (p->type) == ASN1_ETYPE_TAG) &&
!(p->type & CONST_EXPLICIT) && !(p->type & CONST_IMPLICIT))
{
if (node->type & CONST_EXPLICIT)
p->type |= CONST_EXPLICIT;
else
p->type |= CONST_IMPLICIT;
}
if (p->down)
{
p = p->down;
}
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_get_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
return ASN1_SUCCESS;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,078
|
_asn1_set_name (asn1_node node, const char *name)
{
unsigned int nsize;
if (node == NULL)
return node;
if (name == NULL)
{
node->name[0] = 0;
node->name_hash = hash_pjw_bare (node->name, 0);
return node;
}
nsize = _asn1_str_cpy (node->name, sizeof (node->name), name);
node->name_hash = hash_pjw_bare (node->name, nsize);
return node;
}
|
Overflow
| 0
|
_asn1_set_name (asn1_node node, const char *name)
{
unsigned int nsize;
if (node == NULL)
return node;
if (name == NULL)
{
node->name[0] = 0;
node->name_hash = hash_pjw_bare (node->name, 0);
return node;
}
nsize = _asn1_str_cpy (node->name, sizeof (node->name), name);
node->name_hash = hash_pjw_bare (node->name, nsize);
return node;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,079
|
_asn1_set_right (asn1_node node, asn1_node right)
{
if (node == NULL)
return node;
node->right = right;
if (right)
{
right->left = node;
if (right->up == NULL)
right->up = node->up;
}
return node;
}
|
Overflow
| 0
|
_asn1_set_right (asn1_node node, asn1_node right)
{
if (node == NULL)
return node;
node->right = right;
if (right)
{
right->left = node;
if (right->up == NULL)
right->up = node->up;
}
return node;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,080
|
_asn1_set_value (asn1_node node, const void *value, unsigned int len)
{
if (node == NULL)
return node;
if (node->value)
{
if (node->value != node->small_value)
free (node->value);
node->value = NULL;
node->value_len = 0;
}
if (!len)
return node;
if (len < sizeof (node->small_value))
{
node->value = node->small_value;
}
else
{
node->value = malloc (len);
if (node->value == NULL)
return NULL;
}
node->value_len = len;
memcpy (node->value, value, len);
return node;
}
|
Overflow
| 0
|
_asn1_set_value (asn1_node node, const void *value, unsigned int len)
{
if (node == NULL)
return node;
if (node->value)
{
if (node->value != node->small_value)
free (node->value);
node->value = NULL;
node->value_len = 0;
}
if (!len)
return node;
if (len < sizeof (node->small_value))
{
node->value = node->small_value;
}
else
{
node->value = malloc (len);
if (node->value == NULL)
return NULL;
}
node->value_len = len;
memcpy (node->value, value, len);
return node;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,081
|
_asn1_set_value_lv (asn1_node node, const void *value, unsigned int len)
{
int len2;
void *temp;
if (node == NULL)
return node;
asn1_length_der (len, NULL, &len2);
temp = malloc (len + len2);
if (temp == NULL)
return NULL;
asn1_octet_der (value, len, temp, &len2);
return _asn1_set_value_m (node, temp, len2);
}
|
Overflow
| 0
|
_asn1_set_value_lv (asn1_node node, const void *value, unsigned int len)
{
int len2;
void *temp;
if (node == NULL)
return node;
asn1_length_der (len, NULL, &len2);
temp = malloc (len + len2);
if (temp == NULL)
return NULL;
asn1_octet_der (value, len, temp, &len2);
return _asn1_set_value_m (node, temp, len2);
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,082
|
_asn1_set_value_m (asn1_node node, void *value, unsigned int len)
{
if (node == NULL)
return node;
if (node->value)
{
if (node->value != node->small_value)
free (node->value);
node->value = NULL;
node->value_len = 0;
}
if (!len)
return node;
node->value = value;
node->value_len = len;
return node;
}
|
Overflow
| 0
|
_asn1_set_value_m (asn1_node node, void *value, unsigned int len)
{
if (node == NULL)
return node;
if (node->value)
{
if (node->value != node->small_value)
free (node->value);
node->value = NULL;
node->value_len = 0;
}
if (!len)
return node;
node->value = value;
node->value_len = len;
return node;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,083
|
_asn1_type_set_config (asn1_node node)
{
asn1_node p, p2;
int move;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
move = DOWN;
while (!((p == node) && (move == UP)))
{
if (move != UP)
{
if (type_field (p->type) == ASN1_ETYPE_SET)
{
p2 = p->down;
while (p2)
{
if (type_field (p2->type) != ASN1_ETYPE_TAG)
p2->type |= CONST_SET | CONST_NOT_USED;
p2 = p2->right;
}
}
move = DOWN;
}
else
move = RIGHT;
if (move == DOWN)
{
if (p->down)
p = p->down;
else
move = RIGHT;
}
if (p == node)
{
move = UP;
continue;
}
if (move == RIGHT)
{
if (p->right)
p = p->right;
else
move = UP;
}
if (move == UP)
p = _asn1_get_up (p);
}
return ASN1_SUCCESS;
}
|
Overflow
| 0
|
_asn1_type_set_config (asn1_node node)
{
asn1_node p, p2;
int move;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
move = DOWN;
while (!((p == node) && (move == UP)))
{
if (move != UP)
{
if (type_field (p->type) == ASN1_ETYPE_SET)
{
p2 = p->down;
while (p2)
{
if (type_field (p2->type) != ASN1_ETYPE_TAG)
p2->type |= CONST_SET | CONST_NOT_USED;
p2 = p2->right;
}
}
move = DOWN;
}
else
move = RIGHT;
if (move == DOWN)
{
if (p->down)
p = p->down;
else
move = RIGHT;
}
if (p == node)
{
move = UP;
continue;
}
if (move == RIGHT)
{
if (p->right)
p = p->right;
else
move = UP;
}
if (move == UP)
p = _asn1_get_up (p);
}
return ASN1_SUCCESS;
}
|
@@ -543,7 +543,7 @@ _asn1_delete_list_and_nodes (void)
char *
-_asn1_ltostr (long v, char *str)
+_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE])
{
long d, r;
char temp[LTOSTR_MAX_SIZE];
@@ -567,7 +567,7 @@ _asn1_ltostr (long v, char *str)
count++;
v = d;
}
- while (v);
+ while (v && ((start+count) < LTOSTR_MAX_SIZE-1));
for (k = 0; k < count; k++)
str[k + start] = temp[start + count - k - 1];
|
CWE-119
| null | null |
3,084
|
ASCIIHexEncoder::ASCIIHexEncoder(Stream *strA):
FilterStream(strA) {
bufPtr = bufEnd = buf;
lineLen = 0;
eof = gFalse;
}
|
Overflow
| 0
|
ASCIIHexEncoder::ASCIIHexEncoder(Stream *strA):
FilterStream(strA) {
bufPtr = bufEnd = buf;
lineLen = 0;
eof = gFalse;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,085
|
ASCIIHexStream::ASCIIHexStream(Stream *strA):
FilterStream(strA) {
buf = EOF;
eof = gFalse;
}
|
Overflow
| 0
|
ASCIIHexStream::ASCIIHexStream(Stream *strA):
FilterStream(strA) {
buf = EOF;
eof = gFalse;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,086
|
BaseStream::BaseStream(Object *dictA, Guint lengthA) {
dict = *dictA;
length = lengthA;
}
|
Overflow
| 0
|
BaseStream::BaseStream(Object *dictA, Guint lengthA) {
dict = *dictA;
length = lengthA;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,087
|
BufStream::BufStream(Stream *strA, int bufSizeA): FilterStream(strA) {
bufSize = bufSizeA;
buf = (int *)gmallocn(bufSize, sizeof(int));
}
|
Overflow
| 0
|
BufStream::BufStream(Stream *strA, int bufSizeA): FilterStream(strA) {
bufSize = bufSizeA;
buf = (int *)gmallocn(bufSize, sizeof(int));
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,088
|
CCITTFaxStream::CCITTFaxStream(Stream *strA, int encodingA, GBool endOfLineA,
GBool byteAlignA, int columnsA, int rowsA,
GBool endOfBlockA, GBool blackA):
FilterStream(strA) {
encoding = encodingA;
endOfLine = endOfLineA;
byteAlign = byteAlignA;
columns = columnsA;
if (columns < 1) {
columns = 1;
} else if (columns > INT_MAX - 2) {
columns = INT_MAX - 2;
}
rows = rowsA;
endOfBlock = endOfBlockA;
black = blackA;
codingLine = (int *)gmallocn_checkoverflow(columns + 1, sizeof(int));
refLine = (int *)gmallocn_checkoverflow(columns + 2, sizeof(int));
if (codingLine != NULL && refLine != NULL) {
eof = gFalse;
codingLine[0] = columns;
} else {
eof = gTrue;
}
row = 0;
nextLine2D = encoding < 0;
inputBits = 0;
a0i = 0;
outputBits = 0;
buf = EOF;
}
|
Overflow
| 0
|
CCITTFaxStream::CCITTFaxStream(Stream *strA, int encodingA, GBool endOfLineA,
GBool byteAlignA, int columnsA, int rowsA,
GBool endOfBlockA, GBool blackA):
FilterStream(strA) {
encoding = encodingA;
endOfLine = endOfLineA;
byteAlign = byteAlignA;
columns = columnsA;
if (columns < 1) {
columns = 1;
} else if (columns > INT_MAX - 2) {
columns = INT_MAX - 2;
}
rows = rowsA;
endOfBlock = endOfBlockA;
black = blackA;
codingLine = (int *)gmallocn_checkoverflow(columns + 1, sizeof(int));
refLine = (int *)gmallocn_checkoverflow(columns + 2, sizeof(int));
if (codingLine != NULL && refLine != NULL) {
eof = gFalse;
codingLine[0] = columns;
} else {
eof = gTrue;
}
row = 0;
nextLine2D = encoding < 0;
inputBits = 0;
a0i = 0;
outputBits = 0;
buf = EOF;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,089
|
CMYKGrayEncoder::CMYKGrayEncoder(Stream *strA):
FilterStream(strA) {
bufPtr = bufEnd = buf;
eof = gFalse;
}
|
Overflow
| 0
|
CMYKGrayEncoder::CMYKGrayEncoder(Stream *strA):
FilterStream(strA) {
bufPtr = bufEnd = buf;
eof = gFalse;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,090
|
CachedFileStream::CachedFileStream(CachedFile *ccA, Guint startA,
GBool limitedA, Guint lengthA, Object *dictA)
: BaseStream(dictA, lengthA)
{
cc = ccA;
start = startA;
limited = limitedA;
length = lengthA;
bufPtr = bufEnd = buf;
bufPos = start;
savePos = 0;
saved = gFalse;
}
|
Overflow
| 0
|
CachedFileStream::CachedFileStream(CachedFile *ccA, Guint startA,
GBool limitedA, Guint lengthA, Object *dictA)
: BaseStream(dictA, lengthA)
{
cc = ccA;
start = startA;
limited = limitedA;
length = lengthA;
bufPtr = bufEnd = buf;
bufPos = start;
savePos = 0;
saved = gFalse;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,091
|
DCTStream::DCTStream(Stream *strA, int colorXformA):
FilterStream(strA) {
int i, j;
colorXform = colorXformA;
progressive = interleaved = gFalse;
width = height = 0;
mcuWidth = mcuHeight = 0;
numComps = 0;
comp = 0;
x = y = dy = 0;
for (i = 0; i < 4; ++i) {
for (j = 0; j < 32; ++j) {
rowBuf[i][j] = NULL;
}
frameBuf[i] = NULL;
}
if (!dctClipInit) {
for (i = -256; i < 0; ++i)
dctClip[dctClipOffset + i] = 0;
for (i = 0; i < 256; ++i)
dctClip[dctClipOffset + i] = i;
for (i = 256; i < 512; ++i)
dctClip[dctClipOffset + i] = 255;
dctClipInit = 1;
}
}
|
Overflow
| 0
|
DCTStream::DCTStream(Stream *strA, int colorXformA):
FilterStream(strA) {
int i, j;
colorXform = colorXformA;
progressive = interleaved = gFalse;
width = height = 0;
mcuWidth = mcuHeight = 0;
numComps = 0;
comp = 0;
x = y = dy = 0;
for (i = 0; i < 4; ++i) {
for (j = 0; j < 32; ++j) {
rowBuf[i][j] = NULL;
}
frameBuf[i] = NULL;
}
if (!dctClipInit) {
for (i = -256; i < 0; ++i)
dctClip[dctClipOffset + i] = 0;
for (i = 0; i < 256; ++i)
dctClip[dctClipOffset + i] = i;
for (i = 256; i < 512; ++i)
dctClip[dctClipOffset + i] = 255;
dctClipInit = 1;
}
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,092
|
EOFStream::EOFStream(Stream *strA):
FilterStream(strA) {
}
|
Overflow
| 0
|
EOFStream::EOFStream(Stream *strA):
FilterStream(strA) {
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,093
|
EmbedStream::EmbedStream(Stream *strA, Object *dictA,
GBool limitedA, Guint lengthA):
BaseStream(dictA, lengthA) {
str = strA;
limited = limitedA;
length = lengthA;
}
|
Overflow
| 0
|
EmbedStream::EmbedStream(Stream *strA, Object *dictA,
GBool limitedA, Guint lengthA):
BaseStream(dictA, lengthA) {
str = strA;
limited = limitedA;
length = lengthA;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,094
|
FileOutStream::FileOutStream (FILE* fa, Guint startA)
{
f = fa;
start = startA;
}
|
Overflow
| 0
|
FileOutStream::FileOutStream (FILE* fa, Guint startA)
{
f = fa;
start = startA;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,095
|
FilterStream::FilterStream(Stream *strA) {
str = strA;
}
|
Overflow
| 0
|
FilterStream::FilterStream(Stream *strA) {
str = strA;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,096
|
FixedLengthEncoder::FixedLengthEncoder(Stream *strA, int lengthA):
FilterStream(strA) {
length = lengthA;
count = 0;
}
|
Overflow
| 0
|
FixedLengthEncoder::FixedLengthEncoder(Stream *strA, int lengthA):
FilterStream(strA) {
length = lengthA;
count = 0;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,097
|
ImageStream::ImageStream(Stream *strA, int widthA, int nCompsA, int nBitsA) {
int imgLineSize;
str = strA;
width = widthA;
nComps = nCompsA;
nBits = nBitsA;
nVals = width * nComps;
inputLineSize = (nVals * nBits + 7) >> 3;
if (nBits <= 0 || nVals > INT_MAX / nBits - 7) {
inputLineSize = -1;
}
inputLine = (Guchar *)gmallocn_checkoverflow(inputLineSize, sizeof(char));
if (nBits == 8) {
imgLine = (Guchar *)inputLine;
} else {
if (nBits == 1) {
imgLineSize = (nVals + 7) & ~7;
} else {
imgLineSize = nVals;
}
if (width > INT_MAX / nComps) {
imgLineSize = -1;
}
imgLine = (Guchar *)gmallocn(imgLineSize, sizeof(Guchar));
}
imgIdx = nVals;
}
|
Overflow
| 0
|
ImageStream::ImageStream(Stream *strA, int widthA, int nCompsA, int nBitsA) {
int imgLineSize;
str = strA;
width = widthA;
nComps = nCompsA;
nBits = nBitsA;
nVals = width * nComps;
inputLineSize = (nVals * nBits + 7) >> 3;
if (nBits <= 0 || nVals > INT_MAX / nBits - 7) {
inputLineSize = -1;
}
inputLine = (Guchar *)gmallocn_checkoverflow(inputLineSize, sizeof(char));
if (nBits == 8) {
imgLine = (Guchar *)inputLine;
} else {
if (nBits == 1) {
imgLineSize = (nVals + 7) & ~7;
} else {
imgLineSize = nVals;
}
if (width > INT_MAX / nComps) {
imgLineSize = -1;
}
imgLine = (Guchar *)gmallocn(imgLineSize, sizeof(Guchar));
}
imgIdx = nVals;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,098
|
LZWStream::LZWStream(Stream *strA, int predictor, int columns, int colors,
int bits, int earlyA):
FilterStream(strA) {
if (predictor != 1) {
pred = new StreamPredictor(this, predictor, columns, colors, bits);
if (!pred->isOk()) {
delete pred;
pred = NULL;
}
} else {
pred = NULL;
}
early = earlyA;
eof = gFalse;
inputBits = 0;
clearTable();
}
|
Overflow
| 0
|
LZWStream::LZWStream(Stream *strA, int predictor, int columns, int colors,
int bits, int earlyA):
FilterStream(strA) {
if (predictor != 1) {
pred = new StreamPredictor(this, predictor, columns, colors, bits);
if (!pred->isOk()) {
delete pred;
pred = NULL;
}
} else {
pred = NULL;
}
early = earlyA;
eof = gFalse;
inputBits = 0;
clearTable();
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
3,099
|
MemStream::MemStream(char *bufA, Guint startA, Guint lengthA, Object *dictA):
BaseStream(dictA, lengthA) {
buf = bufA;
start = startA;
length = lengthA;
bufEnd = buf + start + length;
bufPtr = buf + start;
needFree = gFalse;
}
|
Overflow
| 0
|
MemStream::MemStream(char *bufA, Guint startA, Guint lengthA, Object *dictA):
BaseStream(dictA, lengthA) {
buf = bufA;
start = startA;
length = lengthA;
bufEnd = buf + start + length;
bufPtr = buf + start;
needFree = gFalse;
}
|
@@ -14,7 +14,7 @@
// under GPL version 2 or later
//
// Copyright (C) 2005 Jeff Muizelaar <jeff@infidigm.net>
-// Copyright (C) 2006-2010, 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2006-2010, 2012, 2013 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2007 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
// Copyright (C) 2008 Julien Rebetez <julien@fhtagn.net>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
@@ -1712,8 +1712,9 @@ int CCITTFaxStream::lookChar() {
for (i = 0; i < columns && codingLine[i] < columns; ++i) {
refLine[i] = codingLine[i];
}
- refLine[i++] = columns;
- refLine[i] = columns;
+ for (; i < columns + 2; ++i) {
+ refLine[i] = columns;
+ }
codingLine[0] = 0;
a0i = 0;
b1i = 0;
|
CWE-119
| null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.