idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
7,700
CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){ /* {{{ */ HINSTANCE kernel32; HANDLE hFile; DWORD dwRet; typedef BOOL (WINAPI *gfpnh_func)(HANDLE, LPTSTR, DWORD, DWORD); gfpnh_func pGetFinalPathNameByHandle; kernel32 = LoadLibrary("kernel32.dll"); if (kernel32) { pGetFinalPathNameByHandle = (gfpnh_func)GetProcAddress(kernel32, "GetFinalPathNameByHandleA"); if (pGetFinalPathNameByHandle == NULL) { return -1; } } else { return -1; } hFile = CreateFile(link, // file to open GENERIC_READ, // open for reading FILE_SHARE_READ, // share for reading NULL, // default security OPEN_EXISTING, // existing file only FILE_FLAG_BACKUP_SEMANTICS, // normal file NULL); // no attr. template if( hFile == INVALID_HANDLE_VALUE) { return -1; } dwRet = pGetFinalPathNameByHandle(hFile, target, MAXPATHLEN, VOLUME_NAME_DOS); if(dwRet >= MAXPATHLEN || dwRet == 0) { return -1; } CloseHandle(hFile); if(dwRet > 4) { /* Skip first 4 characters if they are "\??\" */ if(target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') { char tmp[MAXPATHLEN]; unsigned int offset = 4; dwRet -= 4; /* \??\UNC\ */ if (dwRet > 7 && target[4] == 'U' && target[5] == 'N' && target[6] == 'C') { offset += 2; dwRet -= 2; target[offset] = '\\'; } memcpy(tmp, target + offset, dwRet); memcpy(target, tmp, dwRet); } } target[dwRet] = '\0'; return dwRet; } /* }}} */
DoS Overflow
0
CWD_API int php_sys_readlink(const char *link, char *target, size_t target_len){ /* {{{ */ HINSTANCE kernel32; HANDLE hFile; DWORD dwRet; typedef BOOL (WINAPI *gfpnh_func)(HANDLE, LPTSTR, DWORD, DWORD); gfpnh_func pGetFinalPathNameByHandle; kernel32 = LoadLibrary("kernel32.dll"); if (kernel32) { pGetFinalPathNameByHandle = (gfpnh_func)GetProcAddress(kernel32, "GetFinalPathNameByHandleA"); if (pGetFinalPathNameByHandle == NULL) { return -1; } } else { return -1; } hFile = CreateFile(link, // file to open GENERIC_READ, // open for reading FILE_SHARE_READ, // share for reading NULL, // default security OPEN_EXISTING, // existing file only FILE_FLAG_BACKUP_SEMANTICS, // normal file NULL); // no attr. template if( hFile == INVALID_HANDLE_VALUE) { return -1; } dwRet = pGetFinalPathNameByHandle(hFile, target, MAXPATHLEN, VOLUME_NAME_DOS); if(dwRet >= MAXPATHLEN || dwRet == 0) { return -1; } CloseHandle(hFile); if(dwRet > 4) { /* Skip first 4 characters if they are "\??\" */ if(target[0] == '\\' && target[1] == '\\' && target[2] == '?' && target[3] == '\\') { char tmp[MAXPATHLEN]; unsigned int offset = 4; dwRet -= 4; /* \??\UNC\ */ if (dwRet > 7 && target[4] == 'U' && target[5] == 'N' && target[6] == 'C') { offset += 2; dwRet -= 2; target[offset] = '\\'; } memcpy(tmp, target + offset, dwRet); memcpy(target, tmp, dwRet); } } target[dwRet] = '\0'; return dwRet; } /* }}} */
@@ -621,14 +621,14 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ memcmp(path, (*bucket)->path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; } - + free(r); return; } else { @@ -704,7 +704,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - /* if the pointers match then only subtract the length of the path */ + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { @@ -1159,7 +1159,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int add_slash; void *tmp; - if (path_length == 0 || path_length >= MAXPATHLEN-1) { + if (path_length <= 0 || path_length >= MAXPATHLEN-1) { #ifdef TSRM_WIN32 # if _MSC_VER < 1300 errno = EINVAL;
CWE-190
null
null
7,701
CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{{ */ { WIN32_FILE_ATTRIBUTE_DATA data; __int64 t; const size_t path_len = strlen(path); if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) { return stat(path, buf); } if (path_len >= 1 && path[1] == ':') { if (path[0] >= 'A' && path[0] <= 'Z') { buf->st_dev = buf->st_rdev = path[0] - 'A'; } else { buf->st_dev = buf->st_rdev = path[0] - 'a'; } } else if (IS_UNC_PATH(path, path_len)) { buf->st_dev = buf->st_rdev = 0; } else { char cur_path[MAXPATHLEN+1]; DWORD len = sizeof(cur_path); char *tmp = cur_path; while(1) { DWORD r = GetCurrentDirectory(len, tmp); if (r < len) { if (tmp[1] == ':') { if (path[0] >= 'A' && path[0] <= 'Z') { buf->st_dev = buf->st_rdev = path[0] - 'A'; } else { buf->st_dev = buf->st_rdev = path[0] - 'a'; } } else { buf->st_dev = buf->st_rdev = -1; } break; } else if (!r) { buf->st_dev = buf->st_rdev = -1; break; } else { len = r+1; tmp = (char*)malloc(len); } } if (tmp != cur_path) { free(tmp); } } buf->st_uid = buf->st_gid = buf->st_ino = 0; if (lstat && data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { /* File is a reparse point. Get the target */ HANDLE hLink = NULL; REPARSE_DATA_BUFFER * pbuffer; unsigned int retlength = 0; TSRM_ALLOCA_FLAG(use_heap_large); hLink = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL); if(hLink == INVALID_HANDLE_VALUE) { return -1; } pbuffer = (REPARSE_DATA_BUFFER *)tsrm_do_alloca(MAXIMUM_REPARSE_DATA_BUFFER_SIZE, use_heap_large); if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) { tsrm_free_alloca(pbuffer, use_heap_large); CloseHandle(hLink); return -1; } CloseHandle(hLink); if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) { buf->st_mode = S_IFLNK; buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6)); } #if 0 /* Not used yet */ else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { buf->st_mode |=; } #endif tsrm_free_alloca(pbuffer, use_heap_large); } else { buf->st_mode = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? (S_IFDIR|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)) : S_IFREG; buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6)); } if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { int len = strlen(path); if (path[len-4] == '.') { if (_memicmp(path+len-3, "exe", 3) == 0 || _memicmp(path+len-3, "com", 3) == 0 || _memicmp(path+len-3, "bat", 3) == 0 || _memicmp(path+len-3, "cmd", 3) == 0) { buf->st_mode |= (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)); } } } buf->st_nlink = 1; t = data.nFileSizeHigh; t = t << 32; t |= data.nFileSizeLow; buf->st_size = t; buf->st_atime = FileTimeToUnixTime(data.ftLastAccessTime); buf->st_ctime = FileTimeToUnixTime(data.ftCreationTime); buf->st_mtime = FileTimeToUnixTime(data.ftLastWriteTime); return 0; } /* }}} */
DoS Overflow
0
CWD_API int php_sys_stat_ex(const char *path, struct stat *buf, int lstat) /* {{{ */ { WIN32_FILE_ATTRIBUTE_DATA data; __int64 t; const size_t path_len = strlen(path); if (!GetFileAttributesEx(path, GetFileExInfoStandard, &data)) { return stat(path, buf); } if (path_len >= 1 && path[1] == ':') { if (path[0] >= 'A' && path[0] <= 'Z') { buf->st_dev = buf->st_rdev = path[0] - 'A'; } else { buf->st_dev = buf->st_rdev = path[0] - 'a'; } } else if (IS_UNC_PATH(path, path_len)) { buf->st_dev = buf->st_rdev = 0; } else { char cur_path[MAXPATHLEN+1]; DWORD len = sizeof(cur_path); char *tmp = cur_path; while(1) { DWORD r = GetCurrentDirectory(len, tmp); if (r < len) { if (tmp[1] == ':') { if (path[0] >= 'A' && path[0] <= 'Z') { buf->st_dev = buf->st_rdev = path[0] - 'A'; } else { buf->st_dev = buf->st_rdev = path[0] - 'a'; } } else { buf->st_dev = buf->st_rdev = -1; } break; } else if (!r) { buf->st_dev = buf->st_rdev = -1; break; } else { len = r+1; tmp = (char*)malloc(len); } } if (tmp != cur_path) { free(tmp); } } buf->st_uid = buf->st_gid = buf->st_ino = 0; if (lstat && data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { /* File is a reparse point. Get the target */ HANDLE hLink = NULL; REPARSE_DATA_BUFFER * pbuffer; unsigned int retlength = 0; TSRM_ALLOCA_FLAG(use_heap_large); hLink = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT|FILE_FLAG_BACKUP_SEMANTICS, NULL); if(hLink == INVALID_HANDLE_VALUE) { return -1; } pbuffer = (REPARSE_DATA_BUFFER *)tsrm_do_alloca(MAXIMUM_REPARSE_DATA_BUFFER_SIZE, use_heap_large); if(!DeviceIoControl(hLink, FSCTL_GET_REPARSE_POINT, NULL, 0, pbuffer, MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &retlength, NULL)) { tsrm_free_alloca(pbuffer, use_heap_large); CloseHandle(hLink); return -1; } CloseHandle(hLink); if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) { buf->st_mode = S_IFLNK; buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6)); } #if 0 /* Not used yet */ else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { buf->st_mode |=; } #endif tsrm_free_alloca(pbuffer, use_heap_large); } else { buf->st_mode = (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? (S_IFDIR|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)) : S_IFREG; buf->st_mode |= (data.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6)); } if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) { int len = strlen(path); if (path[len-4] == '.') { if (_memicmp(path+len-3, "exe", 3) == 0 || _memicmp(path+len-3, "com", 3) == 0 || _memicmp(path+len-3, "bat", 3) == 0 || _memicmp(path+len-3, "cmd", 3) == 0) { buf->st_mode |= (S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)); } } } buf->st_nlink = 1; t = data.nFileSizeHigh; t = t << 32; t |= data.nFileSizeLow; buf->st_size = t; buf->st_atime = FileTimeToUnixTime(data.ftLastAccessTime); buf->st_ctime = FileTimeToUnixTime(data.ftCreationTime); buf->st_mtime = FileTimeToUnixTime(data.ftLastWriteTime); return 0; } /* }}} */
@@ -621,14 +621,14 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ memcmp(path, (*bucket)->path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; } - + free(r); return; } else { @@ -704,7 +704,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - /* if the pointers match then only subtract the length of the path */ + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { @@ -1159,7 +1159,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int add_slash; void *tmp; - if (path_length == 0 || path_length >= MAXPATHLEN-1) { + if (path_length <= 0 || path_length >= MAXPATHLEN-1) { #ifdef TSRM_WIN32 # if _MSC_VER < 1300 errno = EINVAL;
CWE-190
null
null
7,702
CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D) { return CWDG(realpath_cache); }
DoS Overflow
0
CWD_API realpath_cache_bucket** realpath_cache_get_buckets(TSRMLS_D) { return CWDG(realpath_cache); }
@@ -621,14 +621,14 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ memcmp(path, (*bucket)->path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; } - + free(r); return; } else { @@ -704,7 +704,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - /* if the pointers match then only subtract the length of the path */ + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { @@ -1159,7 +1159,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int add_slash; void *tmp; - if (path_length == 0 || path_length >= MAXPATHLEN-1) { + if (path_length <= 0 || path_length >= MAXPATHLEN-1) { #ifdef TSRM_WIN32 # if _MSC_VER < 1300 errno = EINVAL;
CWE-190
null
null
7,703
CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */ { return realpath_cache_find(path, path_len, t TSRMLS_CC); } /* }}} */
DoS Overflow
0
CWD_API realpath_cache_bucket* realpath_cache_lookup(const char *path, int path_len, time_t t TSRMLS_DC) /* {{{ */ { return realpath_cache_find(path, path_len, t TSRMLS_CC); } /* }}} */
@@ -621,14 +621,14 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ memcmp(path, (*bucket)->path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; } - + free(r); return; } else { @@ -704,7 +704,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - /* if the pointers match then only subtract the length of the path */ + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { @@ -1159,7 +1159,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int add_slash; void *tmp; - if (path_length == 0 || path_length >= MAXPATHLEN-1) { + if (path_length <= 0 || path_length >= MAXPATHLEN-1) { #ifdef TSRM_WIN32 # if _MSC_VER < 1300 errno = EINVAL;
CWE-190
null
null
7,704
CWD_API int realpath_cache_max_buckets(TSRMLS_D) { return (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); }
DoS Overflow
0
CWD_API int realpath_cache_max_buckets(TSRMLS_D) { return (sizeof(CWDG(realpath_cache)) / sizeof(CWDG(realpath_cache)[0])); }
@@ -621,14 +621,14 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ memcmp(path, (*bucket)->path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; } - + free(r); return; } else { @@ -704,7 +704,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - /* if the pointers match then only subtract the length of the path */ + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { @@ -1159,7 +1159,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int add_slash; void *tmp; - if (path_length == 0 || path_length >= MAXPATHLEN-1) { + if (path_length <= 0 || path_length >= MAXPATHLEN-1) { #ifdef TSRM_WIN32 # if _MSC_VER < 1300 errno = EINVAL;
CWE-190
null
null
7,705
CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{ */ { cwd_state new_state; char cwd[MAXPATHLEN]; /* realpath("") returns CWD */ if (!*path) { new_state.cwd = (char*)malloc(1); if (new_state.cwd == NULL) { return NULL; } new_state.cwd[0] = '\0'; new_state.cwd_length = 0; if (VCWD_GETCWD(cwd, MAXPATHLEN)) { path = cwd; } } else if (!IS_ABSOLUTE_PATH(path, strlen(path)) && VCWD_GETCWD(cwd, MAXPATHLEN)) { new_state.cwd = strdup(cwd); new_state.cwd_length = strlen(cwd); } else { new_state.cwd = (char*)malloc(1); if (new_state.cwd == NULL) { return NULL; } new_state.cwd[0] = '\0'; new_state.cwd_length = 0; } if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) { free(new_state.cwd); return NULL; } if (real_path) { int copy_len = new_state.cwd_length>MAXPATHLEN-1 ? MAXPATHLEN-1 : new_state.cwd_length; memcpy(real_path, new_state.cwd, copy_len); real_path[copy_len] = '\0'; free(new_state.cwd); return real_path; } else { return new_state.cwd; } } /* }}} */
DoS Overflow
0
CWD_API char *tsrm_realpath(const char *path, char *real_path TSRMLS_DC) /* {{{ */ { cwd_state new_state; char cwd[MAXPATHLEN]; /* realpath("") returns CWD */ if (!*path) { new_state.cwd = (char*)malloc(1); if (new_state.cwd == NULL) { return NULL; } new_state.cwd[0] = '\0'; new_state.cwd_length = 0; if (VCWD_GETCWD(cwd, MAXPATHLEN)) { path = cwd; } } else if (!IS_ABSOLUTE_PATH(path, strlen(path)) && VCWD_GETCWD(cwd, MAXPATHLEN)) { new_state.cwd = strdup(cwd); new_state.cwd_length = strlen(cwd); } else { new_state.cwd = (char*)malloc(1); if (new_state.cwd == NULL) { return NULL; } new_state.cwd[0] = '\0'; new_state.cwd_length = 0; } if (virtual_file_ex(&new_state, path, NULL, CWD_REALPATH TSRMLS_CC)) { free(new_state.cwd); return NULL; } if (real_path) { int copy_len = new_state.cwd_length>MAXPATHLEN-1 ? MAXPATHLEN-1 : new_state.cwd_length; memcpy(real_path, new_state.cwd, copy_len); real_path[copy_len] = '\0'; free(new_state.cwd); return real_path; } else { return new_state.cwd; } } /* }}} */
@@ -621,14 +621,14 @@ CWD_API void realpath_cache_del(const char *path, int path_len TSRMLS_DC) /* {{{ memcmp(path, (*bucket)->path, path_len) == 0) { realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1 + r->realpath_len + 1; } - + free(r); return; } else { @@ -704,7 +704,7 @@ static inline realpath_cache_bucket* realpath_cache_find(const char *path, int p realpath_cache_bucket *r = *bucket; *bucket = (*bucket)->next; - /* if the pointers match then only subtract the length of the path */ + /* if the pointers match then only subtract the length of the path */ if(r->path == r->realpath) { CWDG(realpath_cache_size) -= sizeof(realpath_cache_bucket) + r->path_len + 1; } else { @@ -1159,7 +1159,7 @@ CWD_API int virtual_file_ex(cwd_state *state, const char *path, verify_path_func int add_slash; void *tmp; - if (path_length == 0 || path_length >= MAXPATHLEN-1) { + if (path_length <= 0 || path_length >= MAXPATHLEN-1) { #ifdef TSRM_WIN32 # if _MSC_VER < 1300 errno = EINVAL;
CWE-190
null
null
7,706
PHP_FUNCTION(urlencode) { char *in_str, *out_str; int in_str_len, out_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in_str, &in_str_len) == FAILURE) { return; } out_str = php_url_encode(in_str, in_str_len, &out_str_len); RETURN_STRINGL(out_str, out_str_len, 0); }
DoS Overflow
0
PHP_FUNCTION(urlencode) { char *in_str, *out_str; int in_str_len, out_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in_str, &in_str_len) == FAILURE) { return; } out_str = php_url_encode(in_str, in_str_len, &out_str_len); RETURN_STRINGL(out_str, out_str_len, 0); }
@@ -320,7 +320,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) nohost: if ((p = memchr(s, '?', (ue - s)))) { - pp = strchr(s, '#'); + pp = memchr(s, '#', (ue - s)); if (pp && pp < p) { if (pp - s) {
CWE-119
null
null
7,707
PHP_FUNCTION(rawurlencode) { char *in_str, *out_str; int in_str_len, out_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in_str, &in_str_len) == FAILURE) { return; } out_str = php_raw_url_encode(in_str, in_str_len, &out_str_len); RETURN_STRINGL(out_str, out_str_len, 0); }
DoS Overflow
0
PHP_FUNCTION(rawurlencode) { char *in_str, *out_str; int in_str_len, out_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in_str, &in_str_len) == FAILURE) { return; } out_str = php_raw_url_encode(in_str, in_str_len, &out_str_len); RETURN_STRINGL(out_str, out_str_len, 0); }
@@ -320,7 +320,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) nohost: if ((p = memchr(s, '?', (ue - s)))) { - pp = strchr(s, '#'); + pp = memchr(s, '#', (ue - s)); if (pp && pp < p) { if (pp - s) {
CWE-119
null
null
7,708
PHP_FUNCTION(rawurldecode) { char *in_str, *out_str; int in_str_len, out_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in_str, &in_str_len) == FAILURE) { return; } out_str = estrndup(in_str, in_str_len); out_str_len = php_raw_url_decode(out_str, in_str_len); RETURN_STRINGL(out_str, out_str_len, 0); }
DoS Overflow
0
PHP_FUNCTION(rawurldecode) { char *in_str, *out_str; int in_str_len, out_str_len; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in_str, &in_str_len) == FAILURE) { return; } out_str = estrndup(in_str, in_str_len); out_str_len = php_raw_url_decode(out_str, in_str_len); RETURN_STRINGL(out_str, out_str_len, 0); }
@@ -320,7 +320,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) nohost: if ((p = memchr(s, '?', (ue - s)))) { - pp = strchr(s, '#'); + pp = memchr(s, '#', (ue - s)); if (pp && pp < p) { if (pp - s) {
CWE-119
null
null
7,709
PHP_FUNCTION(get_headers) { char *url; int url_len; php_stream_context *context; php_stream *stream; zval **prev_val, **hdr = NULL, **h; HashPosition pos; HashTable *hashT; long format = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &url, &url_len, &format) == FAILURE) { return; } context = FG(default_context) ? FG(default_context) : (FG(default_context) = php_stream_context_alloc(TSRMLS_C)); if (!(stream = php_stream_open_wrapper_ex(url, "r", REPORT_ERRORS | STREAM_USE_URL | STREAM_ONLY_GET_HEADERS, NULL, context))) { RETURN_FALSE; } if (!stream->wrapperdata || Z_TYPE_P(stream->wrapperdata) != IS_ARRAY) { php_stream_close(stream); RETURN_FALSE; } array_init(return_value); /* check for curl-wrappers that provide headers via a special "headers" element */ if (zend_hash_find(HASH_OF(stream->wrapperdata), "headers", sizeof("headers"), (void **)&h) != FAILURE && Z_TYPE_PP(h) == IS_ARRAY) { /* curl-wrappers don't load data until the 1st read */ if (!Z_ARRVAL_PP(h)->nNumOfElements) { php_stream_getc(stream); } zend_hash_find(HASH_OF(stream->wrapperdata), "headers", sizeof("headers"), (void **)&h); hashT = Z_ARRVAL_PP(h); } else { hashT = HASH_OF(stream->wrapperdata); } zend_hash_internal_pointer_reset_ex(hashT, &pos); while (zend_hash_get_current_data_ex(hashT, (void**)&hdr, &pos) != FAILURE) { if (!hdr || Z_TYPE_PP(hdr) != IS_STRING) { zend_hash_move_forward_ex(hashT, &pos); continue; } if (!format) { no_name_header: add_next_index_stringl(return_value, Z_STRVAL_PP(hdr), Z_STRLEN_PP(hdr), 1); } else { char c; char *s, *p; if ((p = strchr(Z_STRVAL_PP(hdr), ':'))) { c = *p; *p = '\0'; s = p + 1; while (isspace((int)*(unsigned char *)s)) { s++; } if (zend_hash_find(HASH_OF(return_value), Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), (void **) &prev_val) == FAILURE) { add_assoc_stringl_ex(return_value, Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), s, (Z_STRLEN_PP(hdr) - (s - Z_STRVAL_PP(hdr))), 1); } else { /* some headers may occur more then once, therefor we need to remake the string into an array */ convert_to_array(*prev_val); add_next_index_stringl(*prev_val, s, (Z_STRLEN_PP(hdr) - (s - Z_STRVAL_PP(hdr))), 1); } *p = c; } else { goto no_name_header; } } zend_hash_move_forward_ex(hashT, &pos); } php_stream_close(stream); }
DoS Overflow
0
PHP_FUNCTION(get_headers) { char *url; int url_len; php_stream_context *context; php_stream *stream; zval **prev_val, **hdr = NULL, **h; HashPosition pos; HashTable *hashT; long format = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &url, &url_len, &format) == FAILURE) { return; } context = FG(default_context) ? FG(default_context) : (FG(default_context) = php_stream_context_alloc(TSRMLS_C)); if (!(stream = php_stream_open_wrapper_ex(url, "r", REPORT_ERRORS | STREAM_USE_URL | STREAM_ONLY_GET_HEADERS, NULL, context))) { RETURN_FALSE; } if (!stream->wrapperdata || Z_TYPE_P(stream->wrapperdata) != IS_ARRAY) { php_stream_close(stream); RETURN_FALSE; } array_init(return_value); /* check for curl-wrappers that provide headers via a special "headers" element */ if (zend_hash_find(HASH_OF(stream->wrapperdata), "headers", sizeof("headers"), (void **)&h) != FAILURE && Z_TYPE_PP(h) == IS_ARRAY) { /* curl-wrappers don't load data until the 1st read */ if (!Z_ARRVAL_PP(h)->nNumOfElements) { php_stream_getc(stream); } zend_hash_find(HASH_OF(stream->wrapperdata), "headers", sizeof("headers"), (void **)&h); hashT = Z_ARRVAL_PP(h); } else { hashT = HASH_OF(stream->wrapperdata); } zend_hash_internal_pointer_reset_ex(hashT, &pos); while (zend_hash_get_current_data_ex(hashT, (void**)&hdr, &pos) != FAILURE) { if (!hdr || Z_TYPE_PP(hdr) != IS_STRING) { zend_hash_move_forward_ex(hashT, &pos); continue; } if (!format) { no_name_header: add_next_index_stringl(return_value, Z_STRVAL_PP(hdr), Z_STRLEN_PP(hdr), 1); } else { char c; char *s, *p; if ((p = strchr(Z_STRVAL_PP(hdr), ':'))) { c = *p; *p = '\0'; s = p + 1; while (isspace((int)*(unsigned char *)s)) { s++; } if (zend_hash_find(HASH_OF(return_value), Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), (void **) &prev_val) == FAILURE) { add_assoc_stringl_ex(return_value, Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), s, (Z_STRLEN_PP(hdr) - (s - Z_STRVAL_PP(hdr))), 1); } else { /* some headers may occur more then once, therefor we need to remake the string into an array */ convert_to_array(*prev_val); add_next_index_stringl(*prev_val, s, (Z_STRLEN_PP(hdr) - (s - Z_STRVAL_PP(hdr))), 1); } *p = c; } else { goto no_name_header; } } zend_hash_move_forward_ex(hashT, &pos); } php_stream_close(stream); }
@@ -320,7 +320,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) nohost: if ((p = memchr(s, '?', (ue - s)))) { - pp = strchr(s, '#'); + pp = memchr(s, '#', (ue - s)); if (pp && pp < p) { if (pp - s) {
CWE-119
null
null
7,710
static int php_htoi(char *s) { int value; int c; c = ((unsigned char *)s)[0]; if (isupper(c)) c = tolower(c); value = (c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; c = ((unsigned char *)s)[1]; if (isupper(c)) c = tolower(c); value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10; return (value); }
DoS Overflow
0
static int php_htoi(char *s) { int value; int c; c = ((unsigned char *)s)[0]; if (isupper(c)) c = tolower(c); value = (c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10) * 16; c = ((unsigned char *)s)[1]; if (isupper(c)) c = tolower(c); value += c >= '0' && c <= '9' ? c - '0' : c - 'a' + 10; return (value); }
@@ -320,7 +320,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) nohost: if ((p = memchr(s, '?', (ue - s)))) { - pp = strchr(s, '#'); + pp = memchr(s, '#', (ue - s)); if (pp && pp < p) { if (pp - s) {
CWE-119
null
null
7,711
PHPAPI int php_raw_url_decode(char *str, int len) { char *dest = str; char *data = str; while (len--) { if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) && isxdigit((int) *(data + 2))) { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else *dest = os_toebcdic[(char) php_htoi(data + 1)]; #endif data += 2; len -= 2; } else { *dest = *data; } data++; dest++; } *dest = '\0'; return dest - str; }
DoS Overflow
0
PHPAPI int php_raw_url_decode(char *str, int len) { char *dest = str; char *data = str; while (len--) { if (*data == '%' && len >= 2 && isxdigit((int) *(data + 1)) && isxdigit((int) *(data + 2))) { #ifndef CHARSET_EBCDIC *dest = (char) php_htoi(data + 1); #else *dest = os_toebcdic[(char) php_htoi(data + 1)]; #endif data += 2; len -= 2; } else { *dest = *data; } data++; dest++; } *dest = '\0'; return dest - str; }
@@ -320,7 +320,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) nohost: if ((p = memchr(s, '?', (ue - s)))) { - pp = strchr(s, '#'); + pp = memchr(s, '#', (ue - s)); if (pp && pp < p) { if (pp - s) {
CWE-119
null
null
7,712
stringprep_unichar_to_utf8 (uint32_t c, char *outbuf) { return g_unichar_to_utf8 (c, outbuf); }
DoS
0
stringprep_unichar_to_utf8 (uint32_t c, char *outbuf) { return g_unichar_to_utf8 (c, outbuf); }
@@ -1,5 +1,5 @@ /* nfkc.c --- Unicode normalization utilities. - Copyright (C) 2002-2015 Simon Josefsson + Copyright (C) 2002-2016 Simon Josefsson This file is part of GNU Libidn. @@ -1086,6 +1086,16 @@ stringprep_ucs4_to_utf8 (const uint32_t * str, ssize_t len, char * stringprep_utf8_nfkc_normalize (const char *str, ssize_t len) { + size_t n; + + if (len < 0) + n = strlen (str); + else + n = len; + + if (u8_check ((const uint8_t *) str, n)) + return NULL; + return g_utf8_normalize (str, len, G_NORMALIZE_NFKC); }
CWE-125
null
null
7,713
stringprep_utf8_to_ucs4 (const char *str, ssize_t len, size_t * items_written) { size_t n; if (len < 0) n = strlen (str); else n = len; if (u8_check ((const uint8_t *) str, n)) return NULL; return g_utf8_to_ucs4_fast (str, (glong) len, (glong *) items_written); }
DoS
0
stringprep_utf8_to_ucs4 (const char *str, ssize_t len, size_t * items_written) { size_t n; if (len < 0) n = strlen (str); else n = len; if (u8_check ((const uint8_t *) str, n)) return NULL; return g_utf8_to_ucs4_fast (str, (glong) len, (glong *) items_written); }
@@ -1,5 +1,5 @@ /* nfkc.c --- Unicode normalization utilities. - Copyright (C) 2002-2015 Simon Josefsson + Copyright (C) 2002-2016 Simon Josefsson This file is part of GNU Libidn. @@ -1086,6 +1086,16 @@ stringprep_ucs4_to_utf8 (const uint32_t * str, ssize_t len, char * stringprep_utf8_nfkc_normalize (const char *str, ssize_t len) { + size_t n; + + if (len < 0) + n = strlen (str); + else + n = len; + + if (u8_check ((const uint8_t *) str, n)) + return NULL; + return g_utf8_normalize (str, len, G_NORMALIZE_NFKC); }
CWE-125
null
null
7,714
usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else { printf (_("\ Usage: %s [OPTION]... [STRINGS]...\n\ "), program_name); fputs (_("\ Internationalized Domain Name (IDN) convert STRINGS, or standard input.\n\ \n\ "), stdout); fputs (_("\ Command line interface to the internationalized domain name library.\n\ \n\ All strings are expected to be encoded in the preferred charset used\n\ by your locale. Use `--debug' to find out what this charset is. You\n\ can override the charset used by setting environment variable CHARSET.\n\ \n\ To process a string that starts with `-', for example `-foo', use `--'\n\ to signal the end of parameters, as in `idn --quiet -a -- -foo'.\n\ \n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ -h, --help Print help and exit\n\ -V, --version Print version and exit\n\ "), stdout); fputs (_("\ -s, --stringprep Prepare string according to nameprep profile\n\ -d, --punycode-decode Decode Punycode\n\ -e, --punycode-encode Encode Punycode\n\ -a, --idna-to-ascii Convert to ACE according to IDNA (default mode)\n\ -u, --idna-to-unicode Convert from ACE according to IDNA\n\ "), stdout); fputs (_("\ --allow-unassigned Toggle IDNA AllowUnassigned flag (default off)\n\ --usestd3asciirules Toggle IDNA UseSTD3ASCIIRules flag (default off)\n\ "), stdout); fputs (_("\ --no-tld Don't check string for TLD specific rules\n\ Only for --idna-to-ascii and --idna-to-unicode\n\ "), stdout); fputs (_("\ -n, --nfkc Normalize string according to Unicode v3.2 NFKC\n\ "), stdout); fputs (_("\ -p, --profile=STRING Use specified stringprep profile instead\n\ Valid stringprep profiles: `Nameprep',\n\ `iSCSI', `Nodeprep', `Resourceprep', \n\ `trace', `SASLprep'\n\ "), stdout); fputs (_("\ --debug Print debugging information\n\ --quiet Silent operation\n\ "), stdout); emit_bug_reporting_address (); } exit (status); }
+Info
0
usage (int status) { if (status != EXIT_SUCCESS) fprintf (stderr, _("Try `%s --help' for more information.\n"), program_name); else { printf (_("\ Usage: %s [OPTION]... [STRINGS]...\n\ "), program_name); fputs (_("\ Internationalized Domain Name (IDN) convert STRINGS, or standard input.\n\ \n\ "), stdout); fputs (_("\ Command line interface to the internationalized domain name library.\n\ \n\ All strings are expected to be encoded in the preferred charset used\n\ by your locale. Use `--debug' to find out what this charset is. You\n\ can override the charset used by setting environment variable CHARSET.\n\ \n\ To process a string that starts with `-', for example `-foo', use `--'\n\ to signal the end of parameters, as in `idn --quiet -a -- -foo'.\n\ \n\ Mandatory arguments to long options are mandatory for short options too.\n\ "), stdout); fputs (_("\ -h, --help Print help and exit\n\ -V, --version Print version and exit\n\ "), stdout); fputs (_("\ -s, --stringprep Prepare string according to nameprep profile\n\ -d, --punycode-decode Decode Punycode\n\ -e, --punycode-encode Encode Punycode\n\ -a, --idna-to-ascii Convert to ACE according to IDNA (default mode)\n\ -u, --idna-to-unicode Convert from ACE according to IDNA\n\ "), stdout); fputs (_("\ --allow-unassigned Toggle IDNA AllowUnassigned flag (default off)\n\ --usestd3asciirules Toggle IDNA UseSTD3ASCIIRules flag (default off)\n\ "), stdout); fputs (_("\ --no-tld Don't check string for TLD specific rules\n\ Only for --idna-to-ascii and --idna-to-unicode\n\ "), stdout); fputs (_("\ -n, --nfkc Normalize string according to Unicode v3.2 NFKC\n\ "), stdout); fputs (_("\ -p, --profile=STRING Use specified stringprep profile instead\n\ Valid stringprep profiles: `Nameprep',\n\ `iSCSI', `Nodeprep', `Resourceprep', \n\ `trace', `SASLprep'\n\ "), stdout); fputs (_("\ --debug Print debugging information\n\ --quiet Silent operation\n\ "), stdout); emit_bug_reporting_address (); } exit (status); }
@@ -200,8 +200,9 @@ main (int argc, char *argv[]) error (EXIT_FAILURE, errno, _("input error")); } - if (line[strlen (line) - 1] == '\n') - line[strlen (line) - 1] = '\0'; + if (strlen (line) > 0) + if (line[strlen (line) - 1] == '\n') + line[strlen (line) - 1] = '\0'; if (args_info.stringprep_given) {
CWE-125
null
null
7,715
Destroy_Driver( FT_Driver driver ) { FT_List_Finalize( &driver->faces_list, (FT_List_Destructor)destroy_face, driver->root.memory, driver ); /* check whether we need to drop the driver's glyph loader */ if ( FT_DRIVER_USES_OUTLINES( driver ) ) FT_GlyphLoader_Done( driver->glyph_loader ); }
DoS Exec Code Overflow Mem. Corr.
0
Destroy_Driver( FT_Driver driver ) { FT_List_Finalize( &driver->faces_list, (FT_List_Destructor)destroy_face, driver->root.memory, driver ); /* check whether we need to drop the driver's glyph loader */ if ( FT_DRIVER_USES_OUTLINES( driver ) ) FT_GlyphLoader_Done( driver->glyph_loader ); }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,716
FT_Load_Glyph( FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags ) { FT_Error error; FT_Driver driver; FT_GlyphSlot slot; FT_Library library; FT_Bool autohint = FALSE; FT_Module hinter; if ( !face || !face->size || !face->glyph ) return FT_Err_Invalid_Face_Handle; /* The validity test for `glyph_index' is performed by the */ /* font drivers. */ slot = face->glyph; ft_glyphslot_clear( slot ); driver = face->driver; library = driver->root.library; hinter = library->auto_hinter; /* resolve load flags dependencies */ if ( load_flags & FT_LOAD_NO_RECURSE ) load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM; if ( load_flags & FT_LOAD_NO_SCALE ) { load_flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; load_flags &= ~FT_LOAD_RENDER; } /* * Determine whether we need to auto-hint or not. * The general rules are: * * - Do only auto-hinting if we have a hinter module, a scalable font * format dealing with outlines, and no transforms except simple * slants and/or rotations by integer multiples of 90 degrees. * * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't * have a native font hinter. * * - Otherwise, auto-hint for LIGHT hinting mode. * * - Exception: The font is `tricky' and requires the native hinter to * load properly. */ if ( hinter && !( load_flags & FT_LOAD_NO_HINTING ) && !( load_flags & FT_LOAD_NO_AUTOHINT ) && FT_DRIVER_IS_SCALABLE( driver ) && FT_DRIVER_USES_OUTLINES( driver ) && !FT_IS_TRICKY( face ) && ( ( face->internal->transform_matrix.yx == 0 && face->internal->transform_matrix.xx != 0 ) || ( face->internal->transform_matrix.xx == 0 && face->internal->transform_matrix.yx != 0 ) ) ) { if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) || !FT_DRIVER_HAS_HINTER( driver ) ) autohint = TRUE; else { FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); if ( mode == FT_RENDER_MODE_LIGHT || face->internal->ignore_unpatented_hinter ) autohint = TRUE; } } if ( autohint ) { FT_AutoHinter_Service hinting; /* try to load embedded bitmaps first if available */ /* */ /* XXX: This is really a temporary hack that should disappear */ /* promptly with FreeType 2.1! */ /* */ if ( FT_HAS_FIXED_SIZES( face ) && ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) { error = driver->clazz->load_glyph( slot, face->size, glyph_index, load_flags | FT_LOAD_SBITS_ONLY ); if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP ) goto Load_Ok; } { FT_Face_Internal internal = face->internal; FT_Int transform_flags = internal->transform_flags; /* since the auto-hinter calls FT_Load_Glyph by itself, */ /* make sure that glyphs aren't transformed */ internal->transform_flags = 0; /* load auto-hinted outline */ hinting = (FT_AutoHinter_Service)hinter->clazz->module_interface; error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size, glyph_index, load_flags ); internal->transform_flags = transform_flags; } } else { error = driver->clazz->load_glyph( slot, face->size, glyph_index, load_flags ); if ( error ) goto Exit; if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { /* check that the loaded outline is correct */ error = FT_Outline_Check( &slot->outline ); if ( error ) goto Exit; #ifdef GRID_FIT_METRICS if ( !( load_flags & FT_LOAD_NO_HINTING ) ) ft_glyphslot_grid_fit_metrics( slot, FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); #endif } } Load_Ok: /* compute the advance */ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { slot->advance.x = 0; slot->advance.y = slot->metrics.vertAdvance; } else { slot->advance.x = slot->metrics.horiAdvance; slot->advance.y = 0; } /* compute the linear advance in 16.16 pixels */ if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 && ( FT_IS_SCALABLE( face ) ) ) { FT_Size_Metrics* metrics = &face->size->metrics; /* it's tricky! */ slot->linearHoriAdvance = FT_MulDiv( slot->linearHoriAdvance, metrics->x_scale, 64 ); slot->linearVertAdvance = FT_MulDiv( slot->linearVertAdvance, metrics->y_scale, 64 ); } if ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) == 0 ) { FT_Face_Internal internal = face->internal; /* now, transform the glyph image if needed */ if ( internal->transform_flags ) { /* get renderer */ FT_Renderer renderer = ft_lookup_glyph_renderer( slot ); if ( renderer ) error = renderer->clazz->transform_glyph( renderer, slot, &internal->transform_matrix, &internal->transform_delta ); else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { /* apply `standard' transformation if no renderer is available */ if ( &internal->transform_matrix ) FT_Outline_Transform( &slot->outline, &internal->transform_matrix ); if ( &internal->transform_delta ) FT_Outline_Translate( &slot->outline, internal->transform_delta.x, internal->transform_delta.y ); } /* transform advance */ FT_Vector_Transform( &slot->advance, &internal->transform_matrix ); } } FT_TRACE5(( " x advance: %d\n" , slot->advance.x )); FT_TRACE5(( " y advance: %d\n" , slot->advance.y )); FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance )); FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance )); /* do we need to render the image now? */ if ( !error && slot->format != FT_GLYPH_FORMAT_BITMAP && slot->format != FT_GLYPH_FORMAT_COMPOSITE && load_flags & FT_LOAD_RENDER ) { FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); if ( mode == FT_RENDER_MODE_NORMAL && (load_flags & FT_LOAD_MONOCHROME ) ) mode = FT_RENDER_MODE_MONO; error = FT_Render_Glyph( slot, mode ); } Exit: return error; }
DoS Exec Code Overflow Mem. Corr.
0
FT_Load_Glyph( FT_Face face, FT_UInt glyph_index, FT_Int32 load_flags ) { FT_Error error; FT_Driver driver; FT_GlyphSlot slot; FT_Library library; FT_Bool autohint = FALSE; FT_Module hinter; if ( !face || !face->size || !face->glyph ) return FT_Err_Invalid_Face_Handle; /* The validity test for `glyph_index' is performed by the */ /* font drivers. */ slot = face->glyph; ft_glyphslot_clear( slot ); driver = face->driver; library = driver->root.library; hinter = library->auto_hinter; /* resolve load flags dependencies */ if ( load_flags & FT_LOAD_NO_RECURSE ) load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_IGNORE_TRANSFORM; if ( load_flags & FT_LOAD_NO_SCALE ) { load_flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP; load_flags &= ~FT_LOAD_RENDER; } /* * Determine whether we need to auto-hint or not. * The general rules are: * * - Do only auto-hinting if we have a hinter module, a scalable font * format dealing with outlines, and no transforms except simple * slants and/or rotations by integer multiples of 90 degrees. * * - Then, auto-hint if FT_LOAD_FORCE_AUTOHINT is set or if we don't * have a native font hinter. * * - Otherwise, auto-hint for LIGHT hinting mode. * * - Exception: The font is `tricky' and requires the native hinter to * load properly. */ if ( hinter && !( load_flags & FT_LOAD_NO_HINTING ) && !( load_flags & FT_LOAD_NO_AUTOHINT ) && FT_DRIVER_IS_SCALABLE( driver ) && FT_DRIVER_USES_OUTLINES( driver ) && !FT_IS_TRICKY( face ) && ( ( face->internal->transform_matrix.yx == 0 && face->internal->transform_matrix.xx != 0 ) || ( face->internal->transform_matrix.xx == 0 && face->internal->transform_matrix.yx != 0 ) ) ) { if ( ( load_flags & FT_LOAD_FORCE_AUTOHINT ) || !FT_DRIVER_HAS_HINTER( driver ) ) autohint = TRUE; else { FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); if ( mode == FT_RENDER_MODE_LIGHT || face->internal->ignore_unpatented_hinter ) autohint = TRUE; } } if ( autohint ) { FT_AutoHinter_Service hinting; /* try to load embedded bitmaps first if available */ /* */ /* XXX: This is really a temporary hack that should disappear */ /* promptly with FreeType 2.1! */ /* */ if ( FT_HAS_FIXED_SIZES( face ) && ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) { error = driver->clazz->load_glyph( slot, face->size, glyph_index, load_flags | FT_LOAD_SBITS_ONLY ); if ( !error && slot->format == FT_GLYPH_FORMAT_BITMAP ) goto Load_Ok; } { FT_Face_Internal internal = face->internal; FT_Int transform_flags = internal->transform_flags; /* since the auto-hinter calls FT_Load_Glyph by itself, */ /* make sure that glyphs aren't transformed */ internal->transform_flags = 0; /* load auto-hinted outline */ hinting = (FT_AutoHinter_Service)hinter->clazz->module_interface; error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size, glyph_index, load_flags ); internal->transform_flags = transform_flags; } } else { error = driver->clazz->load_glyph( slot, face->size, glyph_index, load_flags ); if ( error ) goto Exit; if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { /* check that the loaded outline is correct */ error = FT_Outline_Check( &slot->outline ); if ( error ) goto Exit; #ifdef GRID_FIT_METRICS if ( !( load_flags & FT_LOAD_NO_HINTING ) ) ft_glyphslot_grid_fit_metrics( slot, FT_BOOL( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ); #endif } } Load_Ok: /* compute the advance */ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) { slot->advance.x = 0; slot->advance.y = slot->metrics.vertAdvance; } else { slot->advance.x = slot->metrics.horiAdvance; slot->advance.y = 0; } /* compute the linear advance in 16.16 pixels */ if ( ( load_flags & FT_LOAD_LINEAR_DESIGN ) == 0 && ( FT_IS_SCALABLE( face ) ) ) { FT_Size_Metrics* metrics = &face->size->metrics; /* it's tricky! */ slot->linearHoriAdvance = FT_MulDiv( slot->linearHoriAdvance, metrics->x_scale, 64 ); slot->linearVertAdvance = FT_MulDiv( slot->linearVertAdvance, metrics->y_scale, 64 ); } if ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) == 0 ) { FT_Face_Internal internal = face->internal; /* now, transform the glyph image if needed */ if ( internal->transform_flags ) { /* get renderer */ FT_Renderer renderer = ft_lookup_glyph_renderer( slot ); if ( renderer ) error = renderer->clazz->transform_glyph( renderer, slot, &internal->transform_matrix, &internal->transform_delta ); else if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { /* apply `standard' transformation if no renderer is available */ if ( &internal->transform_matrix ) FT_Outline_Transform( &slot->outline, &internal->transform_matrix ); if ( &internal->transform_delta ) FT_Outline_Translate( &slot->outline, internal->transform_delta.x, internal->transform_delta.y ); } /* transform advance */ FT_Vector_Transform( &slot->advance, &internal->transform_matrix ); } } FT_TRACE5(( " x advance: %d\n" , slot->advance.x )); FT_TRACE5(( " y advance: %d\n" , slot->advance.y )); FT_TRACE5(( " linear x advance: %d\n" , slot->linearHoriAdvance )); FT_TRACE5(( " linear y advance: %d\n" , slot->linearVertAdvance )); /* do we need to render the image now? */ if ( !error && slot->format != FT_GLYPH_FORMAT_BITMAP && slot->format != FT_GLYPH_FORMAT_COMPOSITE && load_flags & FT_LOAD_RENDER ) { FT_Render_Mode mode = FT_LOAD_TARGET_MODE( load_flags ); if ( mode == FT_RENDER_MODE_NORMAL && (load_flags & FT_LOAD_MONOCHROME ) ) mode = FT_RENDER_MODE_MONO; error = FT_Render_Glyph( slot, mode ); } Exit: return error; }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,717
FT_New_GlyphSlot( FT_Face face, FT_GlyphSlot *aslot ) { FT_Error error; FT_Driver driver; FT_Driver_Class clazz; FT_Memory memory; FT_GlyphSlot slot; if ( !face || !face->driver ) return FT_Err_Invalid_Argument; driver = face->driver; clazz = driver->clazz; memory = driver->root.memory; FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); if ( !FT_ALLOC( slot, clazz->slot_object_size ) ) { slot->face = face; error = ft_glyphslot_init( slot ); if ( error ) { ft_glyphslot_done( slot ); FT_FREE( slot ); goto Exit; } slot->next = face->glyph; face->glyph = slot; if ( aslot ) *aslot = slot; } else if ( aslot ) *aslot = 0; Exit: FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error )); return error; }
DoS Exec Code Overflow Mem. Corr.
0
FT_New_GlyphSlot( FT_Face face, FT_GlyphSlot *aslot ) { FT_Error error; FT_Driver driver; FT_Driver_Class clazz; FT_Memory memory; FT_GlyphSlot slot; if ( !face || !face->driver ) return FT_Err_Invalid_Argument; driver = face->driver; clazz = driver->clazz; memory = driver->root.memory; FT_TRACE4(( "FT_New_GlyphSlot: Creating new slot object\n" )); if ( !FT_ALLOC( slot, clazz->slot_object_size ) ) { slot->face = face; error = ft_glyphslot_init( slot ); if ( error ) { ft_glyphslot_done( slot ); FT_FREE( slot ); goto Exit; } slot->next = face->glyph; face->glyph = slot; if ( aslot ) *aslot = slot; } else if ( aslot ) *aslot = 0; Exit: FT_TRACE4(( "FT_New_GlyphSlot: Return %d\n", error )); return error; }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,718
FT_Stream_Free( FT_Stream stream, FT_Int external ) { if ( stream ) { FT_Memory memory = stream->memory; FT_Stream_Close( stream ); if ( !external ) FT_FREE( stream ); } }
DoS Exec Code Overflow Mem. Corr.
0
FT_Stream_Free( FT_Stream stream, FT_Int external ) { if ( stream ) { FT_Memory memory = stream->memory; FT_Stream_Close( stream ); if ( !external ) FT_FREE( stream ); } }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,719
FT_Stream_New( FT_Library library, const FT_Open_Args* args, FT_Stream *astream ) { FT_Error error; FT_Memory memory; FT_Stream stream; *astream = 0; if ( !library ) return FT_Err_Invalid_Library_Handle; if ( !args ) return FT_Err_Invalid_Argument; memory = library->memory; if ( FT_NEW( stream ) ) goto Exit; stream->memory = memory; if ( args->flags & FT_OPEN_MEMORY ) { /* create a memory-based stream */ FT_Stream_OpenMemory( stream, (const FT_Byte*)args->memory_base, args->memory_size ); } else if ( args->flags & FT_OPEN_PATHNAME ) { /* create a normal system stream */ error = FT_Stream_Open( stream, args->pathname ); stream->pathname.pointer = args->pathname; } else if ( ( args->flags & FT_OPEN_STREAM ) && args->stream ) { /* use an existing, user-provided stream */ /* in this case, we do not need to allocate a new stream object */ /* since the caller is responsible for closing it himself */ FT_FREE( stream ); stream = args->stream; } else error = FT_Err_Invalid_Argument; if ( error ) FT_FREE( stream ); else stream->memory = memory; /* just to be certain */ *astream = stream; Exit: return error; }
DoS Exec Code Overflow Mem. Corr.
0
FT_Stream_New( FT_Library library, const FT_Open_Args* args, FT_Stream *astream ) { FT_Error error; FT_Memory memory; FT_Stream stream; *astream = 0; if ( !library ) return FT_Err_Invalid_Library_Handle; if ( !args ) return FT_Err_Invalid_Argument; memory = library->memory; if ( FT_NEW( stream ) ) goto Exit; stream->memory = memory; if ( args->flags & FT_OPEN_MEMORY ) { /* create a memory-based stream */ FT_Stream_OpenMemory( stream, (const FT_Byte*)args->memory_base, args->memory_size ); } else if ( args->flags & FT_OPEN_PATHNAME ) { /* create a normal system stream */ error = FT_Stream_Open( stream, args->pathname ); stream->pathname.pointer = args->pathname; } else if ( ( args->flags & FT_OPEN_STREAM ) && args->stream ) { /* use an existing, user-provided stream */ /* in this case, we do not need to allocate a new stream object */ /* since the caller is responsible for closing it himself */ FT_FREE( stream ); stream = args->stream; } else error = FT_Err_Invalid_Argument; if ( error ) FT_FREE( stream ); else stream->memory = memory; /* just to be certain */ *astream = stream; Exit: return error; }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,720
destroy_charmaps( FT_Face face, FT_Memory memory ) { FT_Int n; if ( !face ) return; for ( n = 0; n < face->num_charmaps; n++ ) { FT_CMap cmap = FT_CMAP( face->charmaps[n] ); ft_cmap_done_internal( cmap ); face->charmaps[n] = NULL; } FT_FREE( face->charmaps ); face->num_charmaps = 0; }
DoS Exec Code Overflow Mem. Corr.
0
destroy_charmaps( FT_Face face, FT_Memory memory ) { FT_Int n; if ( !face ) return; for ( n = 0; n < face->num_charmaps; n++ ) { FT_CMap cmap = FT_CMAP( face->charmaps[n] ); ft_cmap_done_internal( cmap ); face->charmaps[n] = NULL; } FT_FREE( face->charmaps ); face->num_charmaps = 0; }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,721
destroy_face( FT_Memory memory, FT_Face face, FT_Driver driver ) { FT_Driver_Class clazz = driver->clazz; /* discard auto-hinting data */ if ( face->autohint.finalizer ) face->autohint.finalizer( face->autohint.data ); /* Discard glyph slots for this face. */ /* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */ while ( face->glyph ) FT_Done_GlyphSlot( face->glyph ); /* discard all sizes for this face */ FT_List_Finalize( &face->sizes_list, (FT_List_Destructor)destroy_size, memory, driver ); face->size = 0; /* now discard client data */ if ( face->generic.finalizer ) face->generic.finalizer( face ); /* discard charmaps */ destroy_charmaps( face, memory ); /* finalize format-specific stuff */ if ( clazz->done_face ) clazz->done_face( face ); /* close the stream for this face if needed */ FT_Stream_Free( face->stream, ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); face->stream = 0; /* get rid of it */ if ( face->internal ) { FT_FREE( face->internal ); } FT_FREE( face ); }
DoS Exec Code Overflow Mem. Corr.
0
destroy_face( FT_Memory memory, FT_Face face, FT_Driver driver ) { FT_Driver_Class clazz = driver->clazz; /* discard auto-hinting data */ if ( face->autohint.finalizer ) face->autohint.finalizer( face->autohint.data ); /* Discard glyph slots for this face. */ /* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */ while ( face->glyph ) FT_Done_GlyphSlot( face->glyph ); /* discard all sizes for this face */ FT_List_Finalize( &face->sizes_list, (FT_List_Destructor)destroy_size, memory, driver ); face->size = 0; /* now discard client data */ if ( face->generic.finalizer ) face->generic.finalizer( face ); /* discard charmaps */ destroy_charmaps( face, memory ); /* finalize format-specific stuff */ if ( clazz->done_face ) clazz->done_face( face ); /* close the stream for this face if needed */ FT_Stream_Free( face->stream, ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); face->stream = 0; /* get rid of it */ if ( face->internal ) { FT_FREE( face->internal ); } FT_FREE( face ); }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,722
destroy_size( FT_Memory memory, FT_Size size, FT_Driver driver ) { /* finalize client-specific data */ if ( size->generic.finalizer ) size->generic.finalizer( size ); /* finalize format-specific stuff */ if ( driver->clazz->done_size ) driver->clazz->done_size( size ); FT_FREE( size->internal ); FT_FREE( size ); }
DoS Exec Code Overflow Mem. Corr.
0
destroy_size( FT_Memory memory, FT_Size size, FT_Driver driver ) { /* finalize client-specific data */ if ( size->generic.finalizer ) size->generic.finalizer( size ); /* finalize format-specific stuff */ if ( driver->clazz->done_size ) driver->clazz->done_size( size ); FT_FREE( size->internal ); FT_FREE( size ); }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,723
find_unicode_charmap( FT_Face face ) { FT_CharMap* first; FT_CharMap* cur; /* caller should have already checked that `face' is valid */ FT_ASSERT( face ); first = face->charmaps; if ( !first ) return FT_Err_Invalid_CharMap_Handle; /* * The original TrueType specification(s) only specified charmap * formats that are capable of mapping 8 or 16 bit character codes to * glyph indices. * * However, recent updates to the Apple and OpenType specifications * introduced new formats that are capable of mapping 32-bit character * codes as well. And these are already used on some fonts, mainly to * map non-BMP Asian ideographs as defined in Unicode. * * For compatibility purposes, these fonts generally come with * *several* Unicode charmaps: * * - One of them in the "old" 16-bit format, that cannot access * all glyphs in the font. * * - Another one in the "new" 32-bit format, that can access all * the glyphs. * * This function has been written to always favor a 32-bit charmap * when found. Otherwise, a 16-bit one is returned when found. */ /* Since the `interesting' table, with IDs (3,10), is normally the */ /* last one, we loop backwards. This loses with type1 fonts with */ /* non-BMP characters (<.0001%), this wins with .ttf with non-BMP */ /* chars (.01% ?), and this is the same about 99.99% of the time! */ cur = first + face->num_charmaps; /* points after the last one */ for ( ; --cur >= first; ) { if ( cur[0]->encoding == FT_ENCODING_UNICODE ) { /* XXX If some new encodings to represent UCS-4 are added, */ /* they should be added here. */ if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT && cur[0]->encoding_id == TT_MS_ID_UCS_4 ) || ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) ) { #ifdef FT_MAX_CHARMAP_CACHEABLE if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) { FT_ERROR(( "find_unicode_charmap: UCS-4 cmap is found " "at too late position (%d)\n", cur - first )); continue; } #endif face->charmap = cur[0]; return FT_Err_Ok; } } } /* We do not have any UCS-4 charmap. */ /* Do the loop again and search for UCS-2 charmaps. */ cur = first + face->num_charmaps; for ( ; --cur >= first; ) { if ( cur[0]->encoding == FT_ENCODING_UNICODE ) { #ifdef FT_MAX_CHARMAP_CACHEABLE if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) { FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found " "at too late position (%d)\n", cur - first )); continue; } #endif face->charmap = cur[0]; return FT_Err_Ok; } } return FT_Err_Invalid_CharMap_Handle; }
DoS Exec Code Overflow Mem. Corr.
0
find_unicode_charmap( FT_Face face ) { FT_CharMap* first; FT_CharMap* cur; /* caller should have already checked that `face' is valid */ FT_ASSERT( face ); first = face->charmaps; if ( !first ) return FT_Err_Invalid_CharMap_Handle; /* * The original TrueType specification(s) only specified charmap * formats that are capable of mapping 8 or 16 bit character codes to * glyph indices. * * However, recent updates to the Apple and OpenType specifications * introduced new formats that are capable of mapping 32-bit character * codes as well. And these are already used on some fonts, mainly to * map non-BMP Asian ideographs as defined in Unicode. * * For compatibility purposes, these fonts generally come with * *several* Unicode charmaps: * * - One of them in the "old" 16-bit format, that cannot access * all glyphs in the font. * * - Another one in the "new" 32-bit format, that can access all * the glyphs. * * This function has been written to always favor a 32-bit charmap * when found. Otherwise, a 16-bit one is returned when found. */ /* Since the `interesting' table, with IDs (3,10), is normally the */ /* last one, we loop backwards. This loses with type1 fonts with */ /* non-BMP characters (<.0001%), this wins with .ttf with non-BMP */ /* chars (.01% ?), and this is the same about 99.99% of the time! */ cur = first + face->num_charmaps; /* points after the last one */ for ( ; --cur >= first; ) { if ( cur[0]->encoding == FT_ENCODING_UNICODE ) { /* XXX If some new encodings to represent UCS-4 are added, */ /* they should be added here. */ if ( ( cur[0]->platform_id == TT_PLATFORM_MICROSOFT && cur[0]->encoding_id == TT_MS_ID_UCS_4 ) || ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) ) { #ifdef FT_MAX_CHARMAP_CACHEABLE if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) { FT_ERROR(( "find_unicode_charmap: UCS-4 cmap is found " "at too late position (%d)\n", cur - first )); continue; } #endif face->charmap = cur[0]; return FT_Err_Ok; } } } /* We do not have any UCS-4 charmap. */ /* Do the loop again and search for UCS-2 charmaps. */ cur = first + face->num_charmaps; for ( ; --cur >= first; ) { if ( cur[0]->encoding == FT_ENCODING_UNICODE ) { #ifdef FT_MAX_CHARMAP_CACHEABLE if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) { FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found " "at too late position (%d)\n", cur - first )); continue; } #endif face->charmap = cur[0]; return FT_Err_Ok; } } return FT_Err_Invalid_CharMap_Handle; }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,724
ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot, FT_ULong size ) { FT_Memory memory = FT_FACE_MEMORY( slot->face ); FT_Error error; if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) FT_FREE( slot->bitmap.buffer ); else slot->internal->flags |= FT_GLYPH_OWN_BITMAP; (void)FT_ALLOC( slot->bitmap.buffer, size ); return error; }
DoS Exec Code Overflow Mem. Corr.
0
ft_glyphslot_alloc_bitmap( FT_GlyphSlot slot, FT_ULong size ) { FT_Memory memory = FT_FACE_MEMORY( slot->face ); FT_Error error; if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) FT_FREE( slot->bitmap.buffer ); else slot->internal->flags |= FT_GLYPH_OWN_BITMAP; (void)FT_ALLOC( slot->bitmap.buffer, size ); return error; }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,725
ft_glyphslot_done( FT_GlyphSlot slot ) { FT_Driver driver = slot->face->driver; FT_Driver_Class clazz = driver->clazz; FT_Memory memory = driver->root.memory; if ( clazz->done_slot ) clazz->done_slot( slot ); /* free bitmap buffer if needed */ ft_glyphslot_free_bitmap( slot ); /* slot->internal might be NULL in out-of-memory situations */ if ( slot->internal ) { /* free glyph loader */ if ( FT_DRIVER_USES_OUTLINES( driver ) ) { FT_GlyphLoader_Done( slot->internal->loader ); slot->internal->loader = 0; } FT_FREE( slot->internal ); } }
DoS Exec Code Overflow Mem. Corr.
0
ft_glyphslot_done( FT_GlyphSlot slot ) { FT_Driver driver = slot->face->driver; FT_Driver_Class clazz = driver->clazz; FT_Memory memory = driver->root.memory; if ( clazz->done_slot ) clazz->done_slot( slot ); /* free bitmap buffer if needed */ ft_glyphslot_free_bitmap( slot ); /* slot->internal might be NULL in out-of-memory situations */ if ( slot->internal ) { /* free glyph loader */ if ( FT_DRIVER_USES_OUTLINES( driver ) ) { FT_GlyphLoader_Done( slot->internal->loader ); slot->internal->loader = 0; } FT_FREE( slot->internal ); } }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,726
ft_glyphslot_free_bitmap( FT_GlyphSlot slot ) { if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) { FT_Memory memory = FT_FACE_MEMORY( slot->face ); FT_FREE( slot->bitmap.buffer ); slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } else { /* assume that the bitmap buffer was stolen or not */ /* allocated from the heap */ slot->bitmap.buffer = NULL; } }
DoS Exec Code Overflow Mem. Corr.
0
ft_glyphslot_free_bitmap( FT_GlyphSlot slot ) { if ( slot->internal && ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) ) { FT_Memory memory = FT_FACE_MEMORY( slot->face ); FT_FREE( slot->bitmap.buffer ); slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; } else { /* assume that the bitmap buffer was stolen or not */ /* allocated from the heap */ slot->bitmap.buffer = NULL; } }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,727
ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot, FT_Bool vertical ) { FT_Glyph_Metrics* metrics = &slot->metrics; FT_Pos right, bottom; if ( vertical ) { metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); right = FT_PIX_CEIL( metrics->vertBearingX + metrics->width ); bottom = FT_PIX_CEIL( metrics->vertBearingY + metrics->height ); metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); metrics->width = right - metrics->vertBearingX; metrics->height = bottom - metrics->vertBearingY; } else { metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); right = FT_PIX_CEIL ( metrics->horiBearingX + metrics->width ); bottom = FT_PIX_FLOOR( metrics->horiBearingY - metrics->height ); metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); metrics->width = right - metrics->horiBearingX; metrics->height = metrics->horiBearingY - bottom; } metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); }
DoS Exec Code Overflow Mem. Corr.
0
ft_glyphslot_grid_fit_metrics( FT_GlyphSlot slot, FT_Bool vertical ) { FT_Glyph_Metrics* metrics = &slot->metrics; FT_Pos right, bottom; if ( vertical ) { metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); right = FT_PIX_CEIL( metrics->vertBearingX + metrics->width ); bottom = FT_PIX_CEIL( metrics->vertBearingY + metrics->height ); metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); metrics->width = right - metrics->vertBearingX; metrics->height = bottom - metrics->vertBearingY; } else { metrics->vertBearingX = FT_PIX_FLOOR( metrics->vertBearingX ); metrics->vertBearingY = FT_PIX_FLOOR( metrics->vertBearingY ); right = FT_PIX_CEIL ( metrics->horiBearingX + metrics->width ); bottom = FT_PIX_FLOOR( metrics->horiBearingY - metrics->height ); metrics->horiBearingX = FT_PIX_FLOOR( metrics->horiBearingX ); metrics->horiBearingY = FT_PIX_CEIL ( metrics->horiBearingY ); metrics->width = right - metrics->horiBearingX; metrics->height = metrics->horiBearingY - bottom; } metrics->horiAdvance = FT_PIX_ROUND( metrics->horiAdvance ); metrics->vertAdvance = FT_PIX_ROUND( metrics->vertAdvance ); }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,728
ft_glyphslot_init( FT_GlyphSlot slot ) { FT_Driver driver = slot->face->driver; FT_Driver_Class clazz = driver->clazz; FT_Memory memory = driver->root.memory; FT_Error error = FT_Err_Ok; FT_Slot_Internal internal = NULL; slot->library = driver->root.library; if ( FT_NEW( internal ) ) goto Exit; slot->internal = internal; if ( FT_DRIVER_USES_OUTLINES( driver ) ) error = FT_GlyphLoader_New( memory, &internal->loader ); if ( !error && clazz->init_slot ) error = clazz->init_slot( slot ); Exit: return error; }
DoS Exec Code Overflow Mem. Corr.
0
ft_glyphslot_init( FT_GlyphSlot slot ) { FT_Driver driver = slot->face->driver; FT_Driver_Class clazz = driver->clazz; FT_Memory memory = driver->root.memory; FT_Error error = FT_Err_Ok; FT_Slot_Internal internal = NULL; slot->library = driver->root.library; if ( FT_NEW( internal ) ) goto Exit; slot->internal = internal; if ( FT_DRIVER_USES_OUTLINES( driver ) ) error = FT_GlyphLoader_New( memory, &internal->loader ); if ( !error && clazz->init_slot ) error = clazz->init_slot( slot ); Exit: return error; }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,729
ft_glyphslot_set_bitmap( FT_GlyphSlot slot, FT_Byte* buffer ) { ft_glyphslot_free_bitmap( slot ); slot->bitmap.buffer = buffer; FT_ASSERT( (slot->internal->flags & FT_GLYPH_OWN_BITMAP) == 0 ); }
DoS Exec Code Overflow Mem. Corr.
0
ft_glyphslot_set_bitmap( FT_GlyphSlot slot, FT_Byte* buffer ) { ft_glyphslot_free_bitmap( slot ); slot->bitmap.buffer = buffer; FT_ASSERT( (slot->internal->flags & FT_GLYPH_OWN_BITMAP) == 0 ); }
@@ -1574,6 +1574,7 @@ FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", i, offsets[i], rlen, flags )); + /* postpone the check of rlen longer than buffer until FT_Stream_Read() */ if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ continue; @@ -1613,6 +1614,10 @@ pfb_data[pfb_pos++] = 0; } + error = FT_Err_Cannot_Open_Resource; + if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) + goto Exit2; + error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); if ( error ) goto Exit2;
CWE-119
null
null
7,730
t42_parse_font_matrix( T42_Face face, T42_Loader loader ) { T42_Parser parser = &loader->parser; FT_Matrix* matrix = &face->type1.font_matrix; FT_Vector* offset = &face->type1.font_offset; FT_Face root = (FT_Face)&face->root; FT_Fixed temp[6]; FT_Fixed temp_scale; (void)T1_ToFixedArray( parser, 6, temp, 3 ); temp_scale = FT_ABS( temp[3] ); /* Set Units per EM based on FontMatrix values. We set the value to */ /* 1000 / temp_scale, because temp_scale was already multiplied by */ /* 1000 (in t1_tofixed, from psobjs.c). */ root->units_per_EM = (FT_UShort)( FT_DivFix( 1000 * 0x10000L, temp_scale ) >> 16 ); /* we need to scale the values by 1.0/temp_scale */ if ( temp_scale != 0x10000L ) { temp[0] = FT_DivFix( temp[0], temp_scale ); temp[1] = FT_DivFix( temp[1], temp_scale ); temp[2] = FT_DivFix( temp[2], temp_scale ); temp[4] = FT_DivFix( temp[4], temp_scale ); temp[5] = FT_DivFix( temp[5], temp_scale ); temp[3] = 0x10000L; } matrix->xx = temp[0]; matrix->yx = temp[1]; matrix->xy = temp[2]; matrix->yy = temp[3]; /* note that the offsets must be expressed in integer font units */ offset->x = temp[4] >> 16; offset->y = temp[5] >> 16; }
DoS Exec Code Overflow
0
t42_parse_font_matrix( T42_Face face, T42_Loader loader ) { T42_Parser parser = &loader->parser; FT_Matrix* matrix = &face->type1.font_matrix; FT_Vector* offset = &face->type1.font_offset; FT_Face root = (FT_Face)&face->root; FT_Fixed temp[6]; FT_Fixed temp_scale; (void)T1_ToFixedArray( parser, 6, temp, 3 ); temp_scale = FT_ABS( temp[3] ); /* Set Units per EM based on FontMatrix values. We set the value to */ /* 1000 / temp_scale, because temp_scale was already multiplied by */ /* 1000 (in t1_tofixed, from psobjs.c). */ root->units_per_EM = (FT_UShort)( FT_DivFix( 1000 * 0x10000L, temp_scale ) >> 16 ); /* we need to scale the values by 1.0/temp_scale */ if ( temp_scale != 0x10000L ) { temp[0] = FT_DivFix( temp[0], temp_scale ); temp[1] = FT_DivFix( temp[1], temp_scale ); temp[2] = FT_DivFix( temp[2], temp_scale ); temp[4] = FT_DivFix( temp[4], temp_scale ); temp[5] = FT_DivFix( temp[5], temp_scale ); temp[3] = 0x10000L; } matrix->xx = temp[0]; matrix->yx = temp[1]; matrix->xy = temp[2]; matrix->yy = temp[3]; /* note that the offsets must be expressed in integer font units */ offset->x = temp[4] >> 16; offset->y = temp[5] >> 16; }
@@ -4,7 +4,7 @@ /* */ /* Type 42 font parser (body). */ /* */ -/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ +/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 by */ /* Roberto Alameda. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -577,6 +577,12 @@ } string_size = T1_ToInt( parser ); + if ( string_size < 0 ) + { + FT_ERROR(( "t42_parse_sfnts: invalid string size\n" )); + error = T42_Err_Invalid_File_Format; + goto Fail; + } T1_Skip_PS_Token( parser ); /* `RD' */ if ( parser->root.error ) @@ -584,13 +590,14 @@ string_buf = parser->root.cursor + 1; /* one space after `RD' */ - parser->root.cursor += string_size + 1; - if ( parser->root.cursor >= limit ) + if ( limit - parser->root.cursor < string_size ) { FT_ERROR(( "t42_parse_sfnts: too many binary data\n" )); error = T42_Err_Invalid_File_Format; goto Fail; } + else + parser->root.cursor += string_size + 1; } if ( !string_buf )
CWE-399
null
null
7,731
FT_Stream_Close( FT_Stream stream ) { if ( stream && stream->close ) stream->close( stream ); }
DoS Exec Code
0
FT_Stream_Close( FT_Stream stream ) { if ( stream && stream->close ) stream->close( stream ); }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,732
FT_Stream_ExtractFrame( FT_Stream stream, FT_ULong count, FT_Byte** pbytes ) { FT_Error error; error = FT_Stream_EnterFrame( stream, count ); if ( !error ) { *pbytes = (FT_Byte*)stream->cursor; /* equivalent to FT_Stream_ExitFrame(), with no memory block release */ stream->cursor = 0; stream->limit = 0; } return error; }
DoS Exec Code
0
FT_Stream_ExtractFrame( FT_Stream stream, FT_ULong count, FT_Byte** pbytes ) { FT_Error error; error = FT_Stream_EnterFrame( stream, count ); if ( !error ) { *pbytes = (FT_Byte*)stream->cursor; /* equivalent to FT_Stream_ExitFrame(), with no memory block release */ stream->cursor = 0; stream->limit = 0; } return error; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,733
FT_Stream_GetChar( FT_Stream stream ) { FT_Char result; FT_ASSERT( stream && stream->cursor ); result = 0; if ( stream->cursor < stream->limit ) result = *stream->cursor++; return result; }
DoS Exec Code
0
FT_Stream_GetChar( FT_Stream stream ) { FT_Char result; FT_ASSERT( stream && stream->cursor ); result = 0; if ( stream->cursor < stream->limit ) result = *stream->cursor++; return result; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,734
FT_Stream_GetLong( FT_Stream stream ) { FT_Byte* p; FT_Long result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 3 < stream->limit ) result = FT_NEXT_LONG( p ); stream->cursor = p; return result; }
DoS Exec Code
0
FT_Stream_GetLong( FT_Stream stream ) { FT_Byte* p; FT_Long result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 3 < stream->limit ) result = FT_NEXT_LONG( p ); stream->cursor = p; return result; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,735
FT_Stream_GetLongLE( FT_Stream stream ) { FT_Byte* p; FT_Long result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 3 < stream->limit ) result = FT_NEXT_LONG_LE( p ); stream->cursor = p; return result; }
DoS Exec Code
0
FT_Stream_GetLongLE( FT_Stream stream ) { FT_Byte* p; FT_Long result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 3 < stream->limit ) result = FT_NEXT_LONG_LE( p ); stream->cursor = p; return result; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,736
FT_Stream_GetOffset( FT_Stream stream ) { FT_Byte* p; FT_Long result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 2 < stream->limit ) result = FT_NEXT_OFF3( p ); stream->cursor = p; return result; }
DoS Exec Code
0
FT_Stream_GetOffset( FT_Stream stream ) { FT_Byte* p; FT_Long result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 2 < stream->limit ) result = FT_NEXT_OFF3( p ); stream->cursor = p; return result; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,737
FT_Stream_GetShort( FT_Stream stream ) { FT_Byte* p; FT_Short result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 1 < stream->limit ) result = FT_NEXT_SHORT( p ); stream->cursor = p; return result; }
DoS Exec Code
0
FT_Stream_GetShort( FT_Stream stream ) { FT_Byte* p; FT_Short result; FT_ASSERT( stream && stream->cursor ); result = 0; p = stream->cursor; if ( p + 1 < stream->limit ) result = FT_NEXT_SHORT( p ); stream->cursor = p; return result; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,738
FT_Stream_OpenMemory( FT_Stream stream, const FT_Byte* base, FT_ULong size ) { stream->base = (FT_Byte*) base; stream->size = size; stream->pos = 0; stream->cursor = 0; stream->read = 0; stream->close = 0; }
DoS Exec Code
0
FT_Stream_OpenMemory( FT_Stream stream, const FT_Byte* base, FT_ULong size ) { stream->base = (FT_Byte*) base; stream->size = size; stream->pos = 0; stream->cursor = 0; stream->read = 0; stream->close = 0; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,739
FT_Stream_Pos( FT_Stream stream ) { return stream->pos; }
DoS Exec Code
0
FT_Stream_Pos( FT_Stream stream ) { return stream->pos; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,740
FT_Stream_ReadAt( FT_Stream stream, FT_ULong pos, FT_Byte* buffer, FT_ULong count ) { FT_Error error = FT_Err_Ok; FT_ULong read_bytes; if ( pos >= stream->size ) { FT_ERROR(( "FT_Stream_ReadAt:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); return FT_Err_Invalid_Stream_Operation; } if ( stream->read ) read_bytes = stream->read( stream, pos, buffer, count ); else { read_bytes = stream->size - pos; if ( read_bytes > count ) read_bytes = count; FT_MEM_COPY( buffer, stream->base + pos, read_bytes ); } stream->pos = pos + read_bytes; if ( read_bytes < count ) { FT_ERROR(( "FT_Stream_ReadAt:" " invalid read; expected %lu bytes, got %lu\n", count, read_bytes )); error = FT_Err_Invalid_Stream_Operation; } return error; }
DoS Exec Code
0
FT_Stream_ReadAt( FT_Stream stream, FT_ULong pos, FT_Byte* buffer, FT_ULong count ) { FT_Error error = FT_Err_Ok; FT_ULong read_bytes; if ( pos >= stream->size ) { FT_ERROR(( "FT_Stream_ReadAt:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); return FT_Err_Invalid_Stream_Operation; } if ( stream->read ) read_bytes = stream->read( stream, pos, buffer, count ); else { read_bytes = stream->size - pos; if ( read_bytes > count ) read_bytes = count; FT_MEM_COPY( buffer, stream->base + pos, read_bytes ); } stream->pos = pos + read_bytes; if ( read_bytes < count ) { FT_ERROR(( "FT_Stream_ReadAt:" " invalid read; expected %lu bytes, got %lu\n", count, read_bytes )); error = FT_Err_Invalid_Stream_Operation; } return error; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,741
FT_Stream_ReadChar( FT_Stream stream, FT_Error* error ) { FT_Byte result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->read ) { if ( stream->read( stream, stream->pos, &result, 1L ) != 1L ) goto Fail; } else { if ( stream->pos < stream->size ) result = stream->base[stream->pos]; else goto Fail; } stream->pos++; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadChar:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
DoS Exec Code
0
FT_Stream_ReadChar( FT_Stream stream, FT_Error* error ) { FT_Byte result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->read ) { if ( stream->read( stream, stream->pos, &result, 1L ) != 1L ) goto Fail; } else { if ( stream->pos < stream->size ) result = stream->base[stream->pos]; else goto Fail; } stream->pos++; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadChar:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,742
FT_Stream_ReadFields( FT_Stream stream, const FT_Frame_Field* fields, void* structure ) { FT_Error error; FT_Bool frame_accessed = 0; FT_Byte* cursor; if ( !fields || !stream ) return FT_Err_Invalid_Argument; cursor = stream->cursor; error = FT_Err_Ok; do { FT_ULong value; FT_Int sign_shift; FT_Byte* p; switch ( fields->value ) { case ft_frame_start: /* access a new frame */ error = FT_Stream_EnterFrame( stream, fields->offset ); if ( error ) goto Exit; frame_accessed = 1; cursor = stream->cursor; fields++; continue; /* loop! */ case ft_frame_bytes: /* read a byte sequence */ case ft_frame_skip: /* skip some bytes */ { FT_UInt len = fields->size; if ( cursor + len > stream->limit ) { error = FT_Err_Invalid_Stream_Operation; goto Exit; } if ( fields->value == ft_frame_bytes ) { p = (FT_Byte*)structure + fields->offset; FT_MEM_COPY( p, cursor, len ); } cursor += len; fields++; continue; } case ft_frame_byte: case ft_frame_schar: /* read a single byte */ value = FT_NEXT_BYTE(cursor); sign_shift = 24; break; case ft_frame_short_be: case ft_frame_ushort_be: /* read a 2-byte big-endian short */ value = FT_NEXT_USHORT(cursor); sign_shift = 16; break; case ft_frame_short_le: case ft_frame_ushort_le: /* read a 2-byte little-endian short */ value = FT_NEXT_USHORT_LE(cursor); sign_shift = 16; break; case ft_frame_long_be: case ft_frame_ulong_be: /* read a 4-byte big-endian long */ value = FT_NEXT_ULONG(cursor); sign_shift = 0; break; case ft_frame_long_le: case ft_frame_ulong_le: /* read a 4-byte little-endian long */ value = FT_NEXT_ULONG_LE(cursor); sign_shift = 0; break; case ft_frame_off3_be: case ft_frame_uoff3_be: /* read a 3-byte big-endian long */ value = FT_NEXT_UOFF3(cursor); sign_shift = 8; break; case ft_frame_off3_le: case ft_frame_uoff3_le: /* read a 3-byte little-endian long */ value = FT_NEXT_UOFF3_LE(cursor); sign_shift = 8; break; default: /* otherwise, exit the loop */ stream->cursor = cursor; goto Exit; } /* now, compute the signed value is necessary */ if ( fields->value & FT_FRAME_OP_SIGNED ) value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift ); /* finally, store the value in the object */ p = (FT_Byte*)structure + fields->offset; switch ( fields->size ) { case (8 / FT_CHAR_BIT): *(FT_Byte*)p = (FT_Byte)value; break; case (16 / FT_CHAR_BIT): *(FT_UShort*)p = (FT_UShort)value; break; case (32 / FT_CHAR_BIT): *(FT_UInt32*)p = (FT_UInt32)value; break; default: /* for 64-bit systems */ *(FT_ULong*)p = (FT_ULong)value; } /* go to next field */ fields++; } while ( 1 ); Exit: /* close the frame if it was opened by this read */ if ( frame_accessed ) FT_Stream_ExitFrame( stream ); return error; }
DoS Exec Code
0
FT_Stream_ReadFields( FT_Stream stream, const FT_Frame_Field* fields, void* structure ) { FT_Error error; FT_Bool frame_accessed = 0; FT_Byte* cursor; if ( !fields || !stream ) return FT_Err_Invalid_Argument; cursor = stream->cursor; error = FT_Err_Ok; do { FT_ULong value; FT_Int sign_shift; FT_Byte* p; switch ( fields->value ) { case ft_frame_start: /* access a new frame */ error = FT_Stream_EnterFrame( stream, fields->offset ); if ( error ) goto Exit; frame_accessed = 1; cursor = stream->cursor; fields++; continue; /* loop! */ case ft_frame_bytes: /* read a byte sequence */ case ft_frame_skip: /* skip some bytes */ { FT_UInt len = fields->size; if ( cursor + len > stream->limit ) { error = FT_Err_Invalid_Stream_Operation; goto Exit; } if ( fields->value == ft_frame_bytes ) { p = (FT_Byte*)structure + fields->offset; FT_MEM_COPY( p, cursor, len ); } cursor += len; fields++; continue; } case ft_frame_byte: case ft_frame_schar: /* read a single byte */ value = FT_NEXT_BYTE(cursor); sign_shift = 24; break; case ft_frame_short_be: case ft_frame_ushort_be: /* read a 2-byte big-endian short */ value = FT_NEXT_USHORT(cursor); sign_shift = 16; break; case ft_frame_short_le: case ft_frame_ushort_le: /* read a 2-byte little-endian short */ value = FT_NEXT_USHORT_LE(cursor); sign_shift = 16; break; case ft_frame_long_be: case ft_frame_ulong_be: /* read a 4-byte big-endian long */ value = FT_NEXT_ULONG(cursor); sign_shift = 0; break; case ft_frame_long_le: case ft_frame_ulong_le: /* read a 4-byte little-endian long */ value = FT_NEXT_ULONG_LE(cursor); sign_shift = 0; break; case ft_frame_off3_be: case ft_frame_uoff3_be: /* read a 3-byte big-endian long */ value = FT_NEXT_UOFF3(cursor); sign_shift = 8; break; case ft_frame_off3_le: case ft_frame_uoff3_le: /* read a 3-byte little-endian long */ value = FT_NEXT_UOFF3_LE(cursor); sign_shift = 8; break; default: /* otherwise, exit the loop */ stream->cursor = cursor; goto Exit; } /* now, compute the signed value is necessary */ if ( fields->value & FT_FRAME_OP_SIGNED ) value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift ); /* finally, store the value in the object */ p = (FT_Byte*)structure + fields->offset; switch ( fields->size ) { case (8 / FT_CHAR_BIT): *(FT_Byte*)p = (FT_Byte)value; break; case (16 / FT_CHAR_BIT): *(FT_UShort*)p = (FT_UShort)value; break; case (32 / FT_CHAR_BIT): *(FT_UInt32*)p = (FT_UInt32)value; break; default: /* for 64-bit systems */ *(FT_ULong*)p = (FT_ULong)value; } /* go to next field */ fields++; } while ( 1 ); Exit: /* close the frame if it was opened by this read */ if ( frame_accessed ) FT_Stream_ExitFrame( stream ); return error; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,743
FT_Stream_ReadLong( FT_Stream stream, FT_Error* error ) { FT_Byte reads[4]; FT_Byte* p = 0; FT_Long result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 3 < stream->size ) { if ( stream->read ) { if ( stream->read( stream, stream->pos, reads, 4L ) != 4L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_LONG( p ); } else goto Fail; stream->pos += 4; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadLong:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
DoS Exec Code
0
FT_Stream_ReadLong( FT_Stream stream, FT_Error* error ) { FT_Byte reads[4]; FT_Byte* p = 0; FT_Long result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 3 < stream->size ) { if ( stream->read ) { if ( stream->read( stream, stream->pos, reads, 4L ) != 4L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_LONG( p ); } else goto Fail; stream->pos += 4; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadLong:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,744
FT_Stream_ReadLongLE( FT_Stream stream, FT_Error* error ) { FT_Byte reads[4]; FT_Byte* p = 0; FT_Long result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 3 < stream->size ) { if ( stream->read ) { if ( stream->read( stream, stream->pos, reads, 4L ) != 4L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_LONG_LE( p ); } else goto Fail; stream->pos += 4; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadLongLE:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
DoS Exec Code
0
FT_Stream_ReadLongLE( FT_Stream stream, FT_Error* error ) { FT_Byte reads[4]; FT_Byte* p = 0; FT_Long result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 3 < stream->size ) { if ( stream->read ) { if ( stream->read( stream, stream->pos, reads, 4L ) != 4L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_LONG_LE( p ); } else goto Fail; stream->pos += 4; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadLongLE:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,745
FT_Stream_ReadOffset( FT_Stream stream, FT_Error* error ) { FT_Byte reads[3]; FT_Byte* p = 0; FT_Long result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 2 < stream->size ) { if ( stream->read ) { if (stream->read( stream, stream->pos, reads, 3L ) != 3L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_OFF3( p ); } else goto Fail; stream->pos += 3; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadOffset:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
DoS Exec Code
0
FT_Stream_ReadOffset( FT_Stream stream, FT_Error* error ) { FT_Byte reads[3]; FT_Byte* p = 0; FT_Long result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 2 < stream->size ) { if ( stream->read ) { if (stream->read( stream, stream->pos, reads, 3L ) != 3L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_OFF3( p ); } else goto Fail; stream->pos += 3; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadOffset:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,746
FT_Stream_ReadShortLE( FT_Stream stream, FT_Error* error ) { FT_Byte reads[2]; FT_Byte* p = 0; FT_Short result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 1 < stream->size ) { if ( stream->read ) { if ( stream->read( stream, stream->pos, reads, 2L ) != 2L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_SHORT_LE( p ); } else goto Fail; stream->pos += 2; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadShortLE:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
DoS Exec Code
0
FT_Stream_ReadShortLE( FT_Stream stream, FT_Error* error ) { FT_Byte reads[2]; FT_Byte* p = 0; FT_Short result = 0; FT_ASSERT( stream ); *error = FT_Err_Ok; if ( stream->pos + 1 < stream->size ) { if ( stream->read ) { if ( stream->read( stream, stream->pos, reads, 2L ) != 2L ) goto Fail; p = reads; } else { p = stream->base + stream->pos; } if ( p ) result = FT_NEXT_SHORT_LE( p ); } else goto Fail; stream->pos += 2; return result; Fail: *error = FT_Err_Invalid_Stream_Operation; FT_ERROR(( "FT_Stream_ReadShortLE:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", stream->pos, stream->size )); return 0; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,747
FT_Stream_ReleaseFrame( FT_Stream stream, FT_Byte** pbytes ) { if ( stream && stream->read ) { FT_Memory memory = stream->memory; #ifdef FT_DEBUG_MEMORY ft_mem_free( memory, *pbytes ); *pbytes = NULL; #else FT_FREE( *pbytes ); #endif } *pbytes = 0; }
DoS Exec Code
0
FT_Stream_ReleaseFrame( FT_Stream stream, FT_Byte** pbytes ) { if ( stream && stream->read ) { FT_Memory memory = stream->memory; #ifdef FT_DEBUG_MEMORY ft_mem_free( memory, *pbytes ); *pbytes = NULL; #else FT_FREE( *pbytes ); #endif } *pbytes = 0; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,748
FT_Stream_Seek( FT_Stream stream, FT_ULong pos ) { FT_Error error = FT_Err_Ok; if ( stream->read ) { if ( stream->read( stream, pos, 0, 0 ) ) { FT_ERROR(( "FT_Stream_Seek:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); error = FT_Err_Invalid_Stream_Operation; } } /* note that seeking to the first position after the file is valid */ else if ( pos > stream->size ) { FT_ERROR(( "FT_Stream_Seek:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); error = FT_Err_Invalid_Stream_Operation; } if ( !error ) stream->pos = pos; return error; }
DoS Exec Code
0
FT_Stream_Seek( FT_Stream stream, FT_ULong pos ) { FT_Error error = FT_Err_Ok; if ( stream->read ) { if ( stream->read( stream, pos, 0, 0 ) ) { FT_ERROR(( "FT_Stream_Seek:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); error = FT_Err_Invalid_Stream_Operation; } } /* note that seeking to the first position after the file is valid */ else if ( pos > stream->size ) { FT_ERROR(( "FT_Stream_Seek:" " invalid i/o; pos = 0x%lx, size = 0x%lx\n", pos, stream->size )); error = FT_Err_Invalid_Stream_Operation; } if ( !error ) stream->pos = pos; return error; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,749
FT_Stream_TryRead( FT_Stream stream, FT_Byte* buffer, FT_ULong count ) { FT_ULong read_bytes = 0; if ( stream->pos >= stream->size ) goto Exit; if ( stream->read ) read_bytes = stream->read( stream, stream->pos, buffer, count ); else { read_bytes = stream->size - stream->pos; if ( read_bytes > count ) read_bytes = count; FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes ); } stream->pos += read_bytes; Exit: return read_bytes; }
DoS Exec Code
0
FT_Stream_TryRead( FT_Stream stream, FT_Byte* buffer, FT_ULong count ) { FT_ULong read_bytes = 0; if ( stream->pos >= stream->size ) goto Exit; if ( stream->read ) read_bytes = stream->read( stream, stream->pos, buffer, count ); else { read_bytes = stream->size - stream->pos; if ( read_bytes > count ) read_bytes = count; FT_MEM_COPY( buffer, stream->base + stream->pos, read_bytes ); } stream->pos += read_bytes; Exit: return read_bytes; }
@@ -287,7 +287,7 @@ { /* check current and new position */ if ( stream->pos >= stream->size || - stream->pos + count > stream->size ) + stream->size - stream->pos < count ) { FT_ERROR(( "FT_Stream_EnterFrame:" " invalid i/o; pos = 0x%lx, count = %lu, size = 0x%lx\n",
CWE-20
null
null
7,750
match_inst(const char **pcur, unsigned *saturate, const struct tgsi_opcode_info *info) { const char *cur = *pcur; /* simple case: the whole string matches the instruction name */ if (str_match_nocase_whole(&cur, info->mnemonic)) { *pcur = cur; *saturate = 0; return TRUE; } if (str_match_no_case(&cur, info->mnemonic)) { /* the instruction has a suffix, figure it out */ if (str_match_nocase_whole(&cur, "_SAT")) { *pcur = cur; *saturate = 1; return TRUE; } } return FALSE; }
DoS Overflow
0
match_inst(const char **pcur, unsigned *saturate, const struct tgsi_opcode_info *info) { const char *cur = *pcur; /* simple case: the whole string matches the instruction name */ if (str_match_nocase_whole(&cur, info->mnemonic)) { *pcur = cur; *saturate = 0; return TRUE; } if (str_match_no_case(&cur, info->mnemonic)) { /* the instruction has a suffix, figure it out */ if (str_match_nocase_whole(&cur, "_SAT")) { *pcur = cur; *saturate = 1; return TRUE; } } return FALSE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,751
static boolean parse_declaration( struct translate_ctx *ctx ) { struct tgsi_full_declaration decl; uint file; struct parsed_dcl_bracket brackets[2]; int num_brackets; uint writemask; const char *cur, *cur2; uint advance; boolean is_vs_input; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (!parse_register_dcl( ctx, &file, brackets, &num_brackets)) return FALSE; if (!parse_opt_writemask( ctx, &writemask )) return FALSE; decl = tgsi_default_full_declaration(); decl.Declaration.File = file; decl.Declaration.UsageMask = writemask; if (num_brackets == 1) { decl.Range.First = brackets[0].first; decl.Range.Last = brackets[0].last; } else { decl.Range.First = brackets[1].first; decl.Range.Last = brackets[1].last; decl.Declaration.Dimension = 1; decl.Dim.Index2D = brackets[0].first; } is_vs_input = (file == TGSI_FILE_INPUT && ctx->processor == TGSI_PROCESSOR_VERTEX); cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',') { cur2 = cur; cur2++; eat_opt_white( &cur2 ); if (str_match_nocase_whole( &cur2, "ARRAY" )) { int arrayid; if (*cur2 != '(') { report_error( ctx, "Expected `('" ); return FALSE; } cur2++; eat_opt_white( &cur2 ); if (!parse_int( &cur2, &arrayid )) { report_error( ctx, "Expected `,'" ); return FALSE; } eat_opt_white( &cur2 ); if (*cur2 != ')') { report_error( ctx, "Expected `)'" ); return FALSE; } cur2++; decl.Declaration.Array = 1; decl.Array.ArrayID = arrayid; ctx->cur = cur = cur2; } } if (*cur == ',' && !is_vs_input) { uint i, j; cur++; eat_opt_white( &cur ); if (file == TGSI_FILE_RESOURCE) { for (i = 0; i < TGSI_TEXTURE_COUNT; i++) { if (str_match_nocase_whole(&cur, tgsi_texture_names[i])) { decl.Resource.Resource = i; break; } } if (i == TGSI_TEXTURE_COUNT) { report_error(ctx, "Expected texture target"); return FALSE; } cur2 = cur; eat_opt_white(&cur2); while (*cur2 == ',') { cur2++; eat_opt_white(&cur2); if (str_match_nocase_whole(&cur2, "RAW")) { decl.Resource.Raw = 1; } else if (str_match_nocase_whole(&cur2, "WR")) { decl.Resource.Writable = 1; } else { break; } cur = cur2; eat_opt_white(&cur2); } ctx->cur = cur; } else if (file == TGSI_FILE_SAMPLER_VIEW) { for (i = 0; i < TGSI_TEXTURE_COUNT; i++) { if (str_match_nocase_whole(&cur, tgsi_texture_names[i])) { decl.SamplerView.Resource = i; break; } } if (i == TGSI_TEXTURE_COUNT) { report_error(ctx, "Expected texture target"); return FALSE; } eat_opt_white( &cur ); if (*cur != ',') { report_error( ctx, "Expected `,'" ); return FALSE; } ++cur; eat_opt_white( &cur ); for (j = 0; j < 4; ++j) { for (i = 0; i < TGSI_RETURN_TYPE_COUNT; ++i) { if (str_match_nocase_whole(&cur, tgsi_return_type_names[i])) { switch (j) { case 0: decl.SamplerView.ReturnTypeX = i; break; case 1: decl.SamplerView.ReturnTypeY = i; break; case 2: decl.SamplerView.ReturnTypeZ = i; break; case 3: decl.SamplerView.ReturnTypeW = i; break; default: assert(0); } break; } } if (i == TGSI_RETURN_TYPE_COUNT) { if (j == 0 || j > 2) { report_error(ctx, "Expected type name"); return FALSE; } break; } else { cur2 = cur; eat_opt_white( &cur2 ); if (*cur2 == ',') { cur2++; eat_opt_white( &cur2 ); cur = cur2; continue; } else break; } } if (j < 4) { decl.SamplerView.ReturnTypeY = decl.SamplerView.ReturnTypeZ = decl.SamplerView.ReturnTypeW = decl.SamplerView.ReturnTypeX; } ctx->cur = cur; } else { if (str_match_nocase_whole(&cur, "LOCAL")) { decl.Declaration.Local = 1; ctx->cur = cur; } cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',') { cur++; eat_opt_white( &cur ); for (i = 0; i < TGSI_SEMANTIC_COUNT; i++) { if (str_match_nocase_whole(&cur, tgsi_semantic_names[i])) { uint index; cur2 = cur; eat_opt_white( &cur2 ); if (*cur2 == '[') { cur2++; eat_opt_white( &cur2 ); if (!parse_uint( &cur2, &index )) { report_error( ctx, "Expected literal integer" ); return FALSE; } eat_opt_white( &cur2 ); if (*cur2 != ']') { report_error( ctx, "Expected `]'" ); return FALSE; } cur2++; decl.Semantic.Index = index; cur = cur2; } decl.Declaration.Semantic = 1; decl.Semantic.Name = i; ctx->cur = cur; break; } } } } } cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',' && !is_vs_input) { uint i; cur++; eat_opt_white( &cur ); for (i = 0; i < TGSI_INTERPOLATE_COUNT; i++) { if (str_match_nocase_whole( &cur, tgsi_interpolate_names[i] )) { decl.Declaration.Interpolate = 1; decl.Interp.Interpolate = i; ctx->cur = cur; break; } } if (i == TGSI_INTERPOLATE_COUNT) { report_error( ctx, "Expected semantic or interpolate attribute" ); return FALSE; } } cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',' && !is_vs_input) { uint i; cur++; eat_opt_white( &cur ); for (i = 0; i < TGSI_INTERPOLATE_LOC_COUNT; i++) { if (str_match_nocase_whole( &cur, tgsi_interpolate_locations[i] )) { decl.Interp.Location = i; ctx->cur = cur; break; } } } advance = tgsi_build_full_declaration( &decl, ctx->tokens_cur, ctx->header, (uint) (ctx->tokens_end - ctx->tokens_cur) ); if (advance == 0) return FALSE; ctx->tokens_cur += advance; return TRUE; }
DoS Overflow
0
static boolean parse_declaration( struct translate_ctx *ctx ) { struct tgsi_full_declaration decl; uint file; struct parsed_dcl_bracket brackets[2]; int num_brackets; uint writemask; const char *cur, *cur2; uint advance; boolean is_vs_input; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (!parse_register_dcl( ctx, &file, brackets, &num_brackets)) return FALSE; if (!parse_opt_writemask( ctx, &writemask )) return FALSE; decl = tgsi_default_full_declaration(); decl.Declaration.File = file; decl.Declaration.UsageMask = writemask; if (num_brackets == 1) { decl.Range.First = brackets[0].first; decl.Range.Last = brackets[0].last; } else { decl.Range.First = brackets[1].first; decl.Range.Last = brackets[1].last; decl.Declaration.Dimension = 1; decl.Dim.Index2D = brackets[0].first; } is_vs_input = (file == TGSI_FILE_INPUT && ctx->processor == TGSI_PROCESSOR_VERTEX); cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',') { cur2 = cur; cur2++; eat_opt_white( &cur2 ); if (str_match_nocase_whole( &cur2, "ARRAY" )) { int arrayid; if (*cur2 != '(') { report_error( ctx, "Expected `('" ); return FALSE; } cur2++; eat_opt_white( &cur2 ); if (!parse_int( &cur2, &arrayid )) { report_error( ctx, "Expected `,'" ); return FALSE; } eat_opt_white( &cur2 ); if (*cur2 != ')') { report_error( ctx, "Expected `)'" ); return FALSE; } cur2++; decl.Declaration.Array = 1; decl.Array.ArrayID = arrayid; ctx->cur = cur = cur2; } } if (*cur == ',' && !is_vs_input) { uint i, j; cur++; eat_opt_white( &cur ); if (file == TGSI_FILE_RESOURCE) { for (i = 0; i < TGSI_TEXTURE_COUNT; i++) { if (str_match_nocase_whole(&cur, tgsi_texture_names[i])) { decl.Resource.Resource = i; break; } } if (i == TGSI_TEXTURE_COUNT) { report_error(ctx, "Expected texture target"); return FALSE; } cur2 = cur; eat_opt_white(&cur2); while (*cur2 == ',') { cur2++; eat_opt_white(&cur2); if (str_match_nocase_whole(&cur2, "RAW")) { decl.Resource.Raw = 1; } else if (str_match_nocase_whole(&cur2, "WR")) { decl.Resource.Writable = 1; } else { break; } cur = cur2; eat_opt_white(&cur2); } ctx->cur = cur; } else if (file == TGSI_FILE_SAMPLER_VIEW) { for (i = 0; i < TGSI_TEXTURE_COUNT; i++) { if (str_match_nocase_whole(&cur, tgsi_texture_names[i])) { decl.SamplerView.Resource = i; break; } } if (i == TGSI_TEXTURE_COUNT) { report_error(ctx, "Expected texture target"); return FALSE; } eat_opt_white( &cur ); if (*cur != ',') { report_error( ctx, "Expected `,'" ); return FALSE; } ++cur; eat_opt_white( &cur ); for (j = 0; j < 4; ++j) { for (i = 0; i < TGSI_RETURN_TYPE_COUNT; ++i) { if (str_match_nocase_whole(&cur, tgsi_return_type_names[i])) { switch (j) { case 0: decl.SamplerView.ReturnTypeX = i; break; case 1: decl.SamplerView.ReturnTypeY = i; break; case 2: decl.SamplerView.ReturnTypeZ = i; break; case 3: decl.SamplerView.ReturnTypeW = i; break; default: assert(0); } break; } } if (i == TGSI_RETURN_TYPE_COUNT) { if (j == 0 || j > 2) { report_error(ctx, "Expected type name"); return FALSE; } break; } else { cur2 = cur; eat_opt_white( &cur2 ); if (*cur2 == ',') { cur2++; eat_opt_white( &cur2 ); cur = cur2; continue; } else break; } } if (j < 4) { decl.SamplerView.ReturnTypeY = decl.SamplerView.ReturnTypeZ = decl.SamplerView.ReturnTypeW = decl.SamplerView.ReturnTypeX; } ctx->cur = cur; } else { if (str_match_nocase_whole(&cur, "LOCAL")) { decl.Declaration.Local = 1; ctx->cur = cur; } cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',') { cur++; eat_opt_white( &cur ); for (i = 0; i < TGSI_SEMANTIC_COUNT; i++) { if (str_match_nocase_whole(&cur, tgsi_semantic_names[i])) { uint index; cur2 = cur; eat_opt_white( &cur2 ); if (*cur2 == '[') { cur2++; eat_opt_white( &cur2 ); if (!parse_uint( &cur2, &index )) { report_error( ctx, "Expected literal integer" ); return FALSE; } eat_opt_white( &cur2 ); if (*cur2 != ']') { report_error( ctx, "Expected `]'" ); return FALSE; } cur2++; decl.Semantic.Index = index; cur = cur2; } decl.Declaration.Semantic = 1; decl.Semantic.Name = i; ctx->cur = cur; break; } } } } } cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',' && !is_vs_input) { uint i; cur++; eat_opt_white( &cur ); for (i = 0; i < TGSI_INTERPOLATE_COUNT; i++) { if (str_match_nocase_whole( &cur, tgsi_interpolate_names[i] )) { decl.Declaration.Interpolate = 1; decl.Interp.Interpolate = i; ctx->cur = cur; break; } } if (i == TGSI_INTERPOLATE_COUNT) { report_error( ctx, "Expected semantic or interpolate attribute" ); return FALSE; } } cur = ctx->cur; eat_opt_white( &cur ); if (*cur == ',' && !is_vs_input) { uint i; cur++; eat_opt_white( &cur ); for (i = 0; i < TGSI_INTERPOLATE_LOC_COUNT; i++) { if (str_match_nocase_whole( &cur, tgsi_interpolate_locations[i] )) { decl.Interp.Location = i; ctx->cur = cur; break; } } } advance = tgsi_build_full_declaration( &decl, ctx->tokens_cur, ctx->header, (uint) (ctx->tokens_end - ctx->tokens_cur) ); if (advance == 0) return FALSE; ctx->tokens_cur += advance; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,752
parse_dst_operand( struct translate_ctx *ctx, struct tgsi_full_dst_register *dst ) { uint file; uint writemask; const char *cur; struct parsed_bracket bracket[2]; int parsed_opt_brackets; if (!parse_register_dst( ctx, &file, &bracket[0] )) return FALSE; if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets)) return FALSE; cur = ctx->cur; eat_opt_white( &cur ); if (!parse_opt_writemask( ctx, &writemask )) return FALSE; dst->Register.File = file; if (parsed_opt_brackets) { dst->Register.Dimension = 1; dst->Dimension.Indirect = 0; dst->Dimension.Dimension = 0; dst->Dimension.Index = bracket[0].index; if (bracket[0].ind_file != TGSI_FILE_NULL) { dst->Dimension.Indirect = 1; dst->DimIndirect.File = bracket[0].ind_file; dst->DimIndirect.Index = bracket[0].ind_index; dst->DimIndirect.Swizzle = bracket[0].ind_comp; dst->DimIndirect.ArrayID = bracket[0].ind_array; } bracket[0] = bracket[1]; } dst->Register.Index = bracket[0].index; dst->Register.WriteMask = writemask; if (bracket[0].ind_file != TGSI_FILE_NULL) { dst->Register.Indirect = 1; dst->Indirect.File = bracket[0].ind_file; dst->Indirect.Index = bracket[0].ind_index; dst->Indirect.Swizzle = bracket[0].ind_comp; dst->Indirect.ArrayID = bracket[0].ind_array; } return TRUE; }
DoS Overflow
0
parse_dst_operand( struct translate_ctx *ctx, struct tgsi_full_dst_register *dst ) { uint file; uint writemask; const char *cur; struct parsed_bracket bracket[2]; int parsed_opt_brackets; if (!parse_register_dst( ctx, &file, &bracket[0] )) return FALSE; if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets)) return FALSE; cur = ctx->cur; eat_opt_white( &cur ); if (!parse_opt_writemask( ctx, &writemask )) return FALSE; dst->Register.File = file; if (parsed_opt_brackets) { dst->Register.Dimension = 1; dst->Dimension.Indirect = 0; dst->Dimension.Dimension = 0; dst->Dimension.Index = bracket[0].index; if (bracket[0].ind_file != TGSI_FILE_NULL) { dst->Dimension.Indirect = 1; dst->DimIndirect.File = bracket[0].ind_file; dst->DimIndirect.Index = bracket[0].ind_index; dst->DimIndirect.Swizzle = bracket[0].ind_comp; dst->DimIndirect.ArrayID = bracket[0].ind_array; } bracket[0] = bracket[1]; } dst->Register.Index = bracket[0].index; dst->Register.WriteMask = writemask; if (bracket[0].ind_file != TGSI_FILE_NULL) { dst->Register.Indirect = 1; dst->Indirect.File = bracket[0].ind_file; dst->Indirect.Index = bracket[0].ind_index; dst->Indirect.Swizzle = bracket[0].ind_comp; dst->Indirect.ArrayID = bracket[0].ind_array; } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,753
parse_file( const char **pcur, uint *file ) { uint i; for (i = 0; i < TGSI_FILE_COUNT; i++) { const char *cur = *pcur; if (str_match_nocase_whole( &cur, tgsi_file_name(i) )) { *pcur = cur; *file = i; return TRUE; } } return FALSE; }
DoS Overflow
0
parse_file( const char **pcur, uint *file ) { uint i; for (i = 0; i < TGSI_FILE_COUNT; i++) { const char *cur = *pcur; if (str_match_nocase_whole( &cur, tgsi_file_name(i) )) { *pcur = cur; *file = i; return TRUE; } } return FALSE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,754
static boolean parse_float( const char **pcur, float *val ) { const char *cur = *pcur; boolean integral_part = FALSE; boolean fractional_part = FALSE; if (*cur == '0' && *(cur + 1) == 'x') { union fi fi; fi.ui = strtoul(cur, NULL, 16); *val = fi.f; cur += 10; goto out; } *val = (float) atof( cur ); if (*cur == '-' || *cur == '+') cur++; if (is_digit( cur )) { cur++; integral_part = TRUE; while (is_digit( cur )) cur++; } if (*cur == '.') { cur++; if (is_digit( cur )) { cur++; fractional_part = TRUE; while (is_digit( cur )) cur++; } } if (!integral_part && !fractional_part) return FALSE; if (uprcase( *cur ) == 'E') { cur++; if (*cur == '-' || *cur == '+') cur++; if (is_digit( cur )) { cur++; while (is_digit( cur )) cur++; } else return FALSE; } out: *pcur = cur; return TRUE; }
DoS Overflow
0
static boolean parse_float( const char **pcur, float *val ) { const char *cur = *pcur; boolean integral_part = FALSE; boolean fractional_part = FALSE; if (*cur == '0' && *(cur + 1) == 'x') { union fi fi; fi.ui = strtoul(cur, NULL, 16); *val = fi.f; cur += 10; goto out; } *val = (float) atof( cur ); if (*cur == '-' || *cur == '+') cur++; if (is_digit( cur )) { cur++; integral_part = TRUE; while (is_digit( cur )) cur++; } if (*cur == '.') { cur++; if (is_digit( cur )) { cur++; fractional_part = TRUE; while (is_digit( cur )) cur++; } } if (!integral_part && !fractional_part) return FALSE; if (uprcase( *cur ) == 'E') { cur++; if (*cur == '-' || *cur == '+') cur++; if (is_digit( cur )) { cur++; while (is_digit( cur )) cur++; } else return FALSE; } out: *pcur = cur; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,755
parse_fs_coord_origin( const char **pcur, uint *fs_coord_origin ) { uint i; for (i = 0; i < Elements(tgsi_fs_coord_origin_names); i++) { const char *cur = *pcur; if (str_match_nocase_whole( &cur, tgsi_fs_coord_origin_names[i])) { *fs_coord_origin = i; *pcur = cur; return TRUE; } } return FALSE; }
DoS Overflow
0
parse_fs_coord_origin( const char **pcur, uint *fs_coord_origin ) { uint i; for (i = 0; i < Elements(tgsi_fs_coord_origin_names); i++) { const char *cur = *pcur; if (str_match_nocase_whole( &cur, tgsi_fs_coord_origin_names[i])) { *fs_coord_origin = i; *pcur = cur; return TRUE; } } return FALSE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,756
parse_fs_coord_pixel_center( const char **pcur, uint *fs_coord_pixel_center ) { uint i; for (i = 0; i < Elements(tgsi_fs_coord_pixel_center_names); i++) { const char *cur = *pcur; if (str_match_nocase_whole( &cur, tgsi_fs_coord_pixel_center_names[i])) { *fs_coord_pixel_center = i; *pcur = cur; return TRUE; } } return FALSE; }
DoS Overflow
0
parse_fs_coord_pixel_center( const char **pcur, uint *fs_coord_pixel_center ) { uint i; for (i = 0; i < Elements(tgsi_fs_coord_pixel_center_names); i++) { const char *cur = *pcur; if (str_match_nocase_whole( &cur, tgsi_fs_coord_pixel_center_names[i])) { *fs_coord_pixel_center = i; *pcur = cur; return TRUE; } } return FALSE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,757
static boolean parse_header( struct translate_ctx *ctx ) { uint processor; if (str_match_nocase_whole( &ctx->cur, "FRAG" )) processor = TGSI_PROCESSOR_FRAGMENT; else if (str_match_nocase_whole( &ctx->cur, "VERT" )) processor = TGSI_PROCESSOR_VERTEX; else if (str_match_nocase_whole( &ctx->cur, "GEOM" )) processor = TGSI_PROCESSOR_GEOMETRY; else if (str_match_nocase_whole( &ctx->cur, "TESS_CTRL" )) processor = TGSI_PROCESSOR_TESS_CTRL; else if (str_match_nocase_whole( &ctx->cur, "TESS_EVAL" )) processor = TGSI_PROCESSOR_TESS_EVAL; else if (str_match_nocase_whole( &ctx->cur, "COMP" )) processor = TGSI_PROCESSOR_COMPUTE; else { report_error( ctx, "Unknown header" ); return FALSE; } if (ctx->tokens_cur >= ctx->tokens_end) return FALSE; ctx->header = (struct tgsi_header *) ctx->tokens_cur++; *ctx->header = tgsi_build_header(); if (ctx->tokens_cur >= ctx->tokens_end) return FALSE; *(struct tgsi_processor *) ctx->tokens_cur++ = tgsi_build_processor( processor, ctx->header ); ctx->processor = processor; return TRUE; }
DoS Overflow
0
static boolean parse_header( struct translate_ctx *ctx ) { uint processor; if (str_match_nocase_whole( &ctx->cur, "FRAG" )) processor = TGSI_PROCESSOR_FRAGMENT; else if (str_match_nocase_whole( &ctx->cur, "VERT" )) processor = TGSI_PROCESSOR_VERTEX; else if (str_match_nocase_whole( &ctx->cur, "GEOM" )) processor = TGSI_PROCESSOR_GEOMETRY; else if (str_match_nocase_whole( &ctx->cur, "TESS_CTRL" )) processor = TGSI_PROCESSOR_TESS_CTRL; else if (str_match_nocase_whole( &ctx->cur, "TESS_EVAL" )) processor = TGSI_PROCESSOR_TESS_EVAL; else if (str_match_nocase_whole( &ctx->cur, "COMP" )) processor = TGSI_PROCESSOR_COMPUTE; else { report_error( ctx, "Unknown header" ); return FALSE; } if (ctx->tokens_cur >= ctx->tokens_end) return FALSE; ctx->header = (struct tgsi_header *) ctx->tokens_cur++; *ctx->header = tgsi_build_header(); if (ctx->tokens_cur >= ctx->tokens_end) return FALSE; *(struct tgsi_processor *) ctx->tokens_cur++ = tgsi_build_processor( processor, ctx->header ); ctx->processor = processor; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,758
static boolean parse_immediate( struct translate_ctx *ctx ) { struct tgsi_full_immediate imm; uint advance; int type; if (*ctx->cur == '[') { uint uindex; ++ctx->cur; eat_opt_white( &ctx->cur ); if (!parse_uint( &ctx->cur, &uindex )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } if (uindex != ctx->num_immediates) { report_error( ctx, "Immediates must be sorted" ); return FALSE; } eat_opt_white( &ctx->cur ); if (*ctx->cur != ']') { report_error( ctx, "Expected `]'" ); return FALSE; } ctx->cur++; } if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } for (type = 0; type < Elements(tgsi_immediate_type_names); ++type) { if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type])) break; } if (type == Elements(tgsi_immediate_type_names)) { report_error( ctx, "Expected immediate type" ); return FALSE; } imm = tgsi_default_full_immediate(); imm.Immediate.NrTokens += 4; imm.Immediate.DataType = type; parse_immediate_data(ctx, type, imm.u); advance = tgsi_build_full_immediate( &imm, ctx->tokens_cur, ctx->header, (uint) (ctx->tokens_end - ctx->tokens_cur) ); if (advance == 0) return FALSE; ctx->tokens_cur += advance; ctx->num_immediates++; return TRUE; }
DoS Overflow
0
static boolean parse_immediate( struct translate_ctx *ctx ) { struct tgsi_full_immediate imm; uint advance; int type; if (*ctx->cur == '[') { uint uindex; ++ctx->cur; eat_opt_white( &ctx->cur ); if (!parse_uint( &ctx->cur, &uindex )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } if (uindex != ctx->num_immediates) { report_error( ctx, "Immediates must be sorted" ); return FALSE; } eat_opt_white( &ctx->cur ); if (*ctx->cur != ']') { report_error( ctx, "Expected `]'" ); return FALSE; } ctx->cur++; } if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } for (type = 0; type < Elements(tgsi_immediate_type_names); ++type) { if (str_match_nocase_whole(&ctx->cur, tgsi_immediate_type_names[type])) break; } if (type == Elements(tgsi_immediate_type_names)) { report_error( ctx, "Expected immediate type" ); return FALSE; } imm = tgsi_default_full_immediate(); imm.Immediate.NrTokens += 4; imm.Immediate.DataType = type; parse_immediate_data(ctx, type, imm.u); advance = tgsi_build_full_immediate( &imm, ctx->tokens_cur, ctx->header, (uint) (ctx->tokens_end - ctx->tokens_cur) ); if (advance == 0) return FALSE; ctx->tokens_cur += advance; ctx->num_immediates++; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,759
static boolean parse_immediate_data(struct translate_ctx *ctx, unsigned type, union tgsi_immediate_data *values) { unsigned i; int ret; eat_opt_white( &ctx->cur ); if (*ctx->cur != '{') { report_error( ctx, "Expected `{'" ); return FALSE; } ctx->cur++; for (i = 0; i < 4; i++) { eat_opt_white( &ctx->cur ); if (i > 0) { if (*ctx->cur != ',') { report_error( ctx, "Expected `,'" ); return FALSE; } ctx->cur++; eat_opt_white( &ctx->cur ); } switch (type) { case TGSI_IMM_FLOAT64: ret = parse_double(&ctx->cur, &values[i].Uint, &values[i+1].Uint); i++; break; case TGSI_IMM_FLOAT32: ret = parse_float(&ctx->cur, &values[i].Float); break; case TGSI_IMM_UINT32: ret = parse_uint(&ctx->cur, &values[i].Uint); break; case TGSI_IMM_INT32: ret = parse_int(&ctx->cur, &values[i].Int); break; default: assert(0); ret = FALSE; break; } if (!ret) { report_error( ctx, "Expected immediate constant" ); return FALSE; } } eat_opt_white( &ctx->cur ); if (*ctx->cur != '}') { report_error( ctx, "Expected `}'" ); return FALSE; } ctx->cur++; return TRUE; }
DoS Overflow
0
static boolean parse_immediate_data(struct translate_ctx *ctx, unsigned type, union tgsi_immediate_data *values) { unsigned i; int ret; eat_opt_white( &ctx->cur ); if (*ctx->cur != '{') { report_error( ctx, "Expected `{'" ); return FALSE; } ctx->cur++; for (i = 0; i < 4; i++) { eat_opt_white( &ctx->cur ); if (i > 0) { if (*ctx->cur != ',') { report_error( ctx, "Expected `,'" ); return FALSE; } ctx->cur++; eat_opt_white( &ctx->cur ); } switch (type) { case TGSI_IMM_FLOAT64: ret = parse_double(&ctx->cur, &values[i].Uint, &values[i+1].Uint); i++; break; case TGSI_IMM_FLOAT32: ret = parse_float(&ctx->cur, &values[i].Float); break; case TGSI_IMM_UINT32: ret = parse_uint(&ctx->cur, &values[i].Uint); break; case TGSI_IMM_INT32: ret = parse_int(&ctx->cur, &values[i].Int); break; default: assert(0); ret = FALSE; break; } if (!ret) { report_error( ctx, "Expected immediate constant" ); return FALSE; } } eat_opt_white( &ctx->cur ); if (*ctx->cur != '}') { report_error( ctx, "Expected `}'" ); return FALSE; } ctx->cur++; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,760
static boolean parse_int( const char **pcur, int *val ) { const char *cur = *pcur; int sign = (*cur == '-' ? -1 : 1); if (*cur == '+' || *cur == '-') cur++; if (parse_uint(&cur, (uint *)val)) { *val *= sign; *pcur = cur; return TRUE; } return FALSE; }
DoS Overflow
0
static boolean parse_int( const char **pcur, int *val ) { const char *cur = *pcur; int sign = (*cur == '-' ? -1 : 1); if (*cur == '+' || *cur == '-') cur++; if (parse_uint(&cur, (uint *)val)) { *val *= sign; *pcur = cur; return TRUE; } return FALSE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,761
static boolean parse_label( struct translate_ctx *ctx, uint *val ) { const char *cur = ctx->cur; if (parse_uint( &cur, val )) { eat_opt_white( &cur ); if (*cur == ':') { cur++; ctx->cur = cur; return TRUE; } } return FALSE; }
DoS Overflow
0
static boolean parse_label( struct translate_ctx *ctx, uint *val ) { const char *cur = ctx->cur; if (parse_uint( &cur, val )) { eat_opt_white( &cur ); if (*cur == ':') { cur++; ctx->cur = cur; return TRUE; } } return FALSE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,762
parse_opt_register_src_bracket( struct translate_ctx *ctx, struct parsed_bracket *brackets, int *parsed_brackets) { const char *cur = ctx->cur; *parsed_brackets = 0; eat_opt_white( &cur ); if (cur[0] == '[') { ++cur; ctx->cur = cur; if (!parse_register_bracket(ctx, brackets)) return FALSE; *parsed_brackets = 1; } return TRUE; }
DoS Overflow
0
parse_opt_register_src_bracket( struct translate_ctx *ctx, struct parsed_bracket *brackets, int *parsed_brackets) { const char *cur = ctx->cur; *parsed_brackets = 0; eat_opt_white( &cur ); if (cur[0] == '[') { ++cur; ctx->cur = cur; if (!parse_register_bracket(ctx, brackets)) return FALSE; *parsed_brackets = 1; } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,763
parse_opt_writemask( struct translate_ctx *ctx, uint *writemask ) { const char *cur; cur = ctx->cur; eat_opt_white( &cur ); if (*cur == '.') { cur++; *writemask = TGSI_WRITEMASK_NONE; eat_opt_white( &cur ); if (uprcase( *cur ) == 'X') { cur++; *writemask |= TGSI_WRITEMASK_X; } if (uprcase( *cur ) == 'Y') { cur++; *writemask |= TGSI_WRITEMASK_Y; } if (uprcase( *cur ) == 'Z') { cur++; *writemask |= TGSI_WRITEMASK_Z; } if (uprcase( *cur ) == 'W') { cur++; *writemask |= TGSI_WRITEMASK_W; } if (*writemask == TGSI_WRITEMASK_NONE) { report_error( ctx, "Writemask expected" ); return FALSE; } ctx->cur = cur; } else { *writemask = TGSI_WRITEMASK_XYZW; } return TRUE; }
DoS Overflow
0
parse_opt_writemask( struct translate_ctx *ctx, uint *writemask ) { const char *cur; cur = ctx->cur; eat_opt_white( &cur ); if (*cur == '.') { cur++; *writemask = TGSI_WRITEMASK_NONE; eat_opt_white( &cur ); if (uprcase( *cur ) == 'X') { cur++; *writemask |= TGSI_WRITEMASK_X; } if (uprcase( *cur ) == 'Y') { cur++; *writemask |= TGSI_WRITEMASK_Y; } if (uprcase( *cur ) == 'Z') { cur++; *writemask |= TGSI_WRITEMASK_Z; } if (uprcase( *cur ) == 'W') { cur++; *writemask |= TGSI_WRITEMASK_W; } if (*writemask == TGSI_WRITEMASK_NONE) { report_error( ctx, "Writemask expected" ); return FALSE; } ctx->cur = cur; } else { *writemask = TGSI_WRITEMASK_XYZW; } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,764
parse_optional_swizzle( struct translate_ctx *ctx, uint *swizzle, boolean *parsed_swizzle, int components) { const char *cur = ctx->cur; *parsed_swizzle = FALSE; eat_opt_white( &cur ); if (*cur == '.') { uint i; cur++; eat_opt_white( &cur ); for (i = 0; i < components; i++) { if (uprcase( *cur ) == 'X') swizzle[i] = TGSI_SWIZZLE_X; else if (uprcase( *cur ) == 'Y') swizzle[i] = TGSI_SWIZZLE_Y; else if (uprcase( *cur ) == 'Z') swizzle[i] = TGSI_SWIZZLE_Z; else if (uprcase( *cur ) == 'W') swizzle[i] = TGSI_SWIZZLE_W; else { report_error( ctx, "Expected register swizzle component `x', `y', `z' or `w'" ); return FALSE; } cur++; } *parsed_swizzle = TRUE; ctx->cur = cur; } return TRUE; }
DoS Overflow
0
parse_optional_swizzle( struct translate_ctx *ctx, uint *swizzle, boolean *parsed_swizzle, int components) { const char *cur = ctx->cur; *parsed_swizzle = FALSE; eat_opt_white( &cur ); if (*cur == '.') { uint i; cur++; eat_opt_white( &cur ); for (i = 0; i < components; i++) { if (uprcase( *cur ) == 'X') swizzle[i] = TGSI_SWIZZLE_X; else if (uprcase( *cur ) == 'Y') swizzle[i] = TGSI_SWIZZLE_Y; else if (uprcase( *cur ) == 'Z') swizzle[i] = TGSI_SWIZZLE_Z; else if (uprcase( *cur ) == 'W') swizzle[i] = TGSI_SWIZZLE_W; else { report_error( ctx, "Expected register swizzle component `x', `y', `z' or `w'" ); return FALSE; } cur++; } *parsed_swizzle = TRUE; ctx->cur = cur; } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,765
static boolean parse_property( struct translate_ctx *ctx ) { struct tgsi_full_property prop; uint property_name; uint values[8]; uint advance; char id[64]; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (!parse_identifier( &ctx->cur, id, sizeof(id) )) { report_error( ctx, "Syntax error" ); return FALSE; } for (property_name = 0; property_name < TGSI_PROPERTY_COUNT; ++property_name) { if (streq_nocase_uprcase(tgsi_property_names[property_name], id)) { break; } } if (property_name >= TGSI_PROPERTY_COUNT) { eat_until_eol( &ctx->cur ); report_error(ctx, "\nError: Unknown property : '%s'\n", id); return TRUE; } eat_opt_white( &ctx->cur ); switch(property_name) { case TGSI_PROPERTY_GS_INPUT_PRIM: case TGSI_PROPERTY_GS_OUTPUT_PRIM: if (!parse_primitive(&ctx->cur, &values[0] )) { report_error( ctx, "Unknown primitive name as property!" ); return FALSE; } if (property_name == TGSI_PROPERTY_GS_INPUT_PRIM && ctx->processor == TGSI_PROCESSOR_GEOMETRY) { ctx->implied_array_size = u_vertices_per_prim(values[0]); } break; case TGSI_PROPERTY_FS_COORD_ORIGIN: if (!parse_fs_coord_origin(&ctx->cur, &values[0] )) { report_error( ctx, "Unknown coord origin as property: must be UPPER_LEFT or LOWER_LEFT!" ); return FALSE; } break; case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: if (!parse_fs_coord_pixel_center(&ctx->cur, &values[0] )) { report_error( ctx, "Unknown coord pixel center as property: must be HALF_INTEGER or INTEGER!" ); return FALSE; } break; case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS: default: if (!parse_uint(&ctx->cur, &values[0] )) { report_error( ctx, "Expected unsigned integer as property!" ); return FALSE; } } prop = tgsi_default_full_property(); prop.Property.PropertyName = property_name; prop.Property.NrTokens += 1; prop.u[0].Data = values[0]; advance = tgsi_build_full_property( &prop, ctx->tokens_cur, ctx->header, (uint) (ctx->tokens_end - ctx->tokens_cur) ); if (advance == 0) return FALSE; ctx->tokens_cur += advance; return TRUE; }
DoS Overflow
0
static boolean parse_property( struct translate_ctx *ctx ) { struct tgsi_full_property prop; uint property_name; uint values[8]; uint advance; char id[64]; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (!parse_identifier( &ctx->cur, id, sizeof(id) )) { report_error( ctx, "Syntax error" ); return FALSE; } for (property_name = 0; property_name < TGSI_PROPERTY_COUNT; ++property_name) { if (streq_nocase_uprcase(tgsi_property_names[property_name], id)) { break; } } if (property_name >= TGSI_PROPERTY_COUNT) { eat_until_eol( &ctx->cur ); report_error(ctx, "\nError: Unknown property : '%s'\n", id); return TRUE; } eat_opt_white( &ctx->cur ); switch(property_name) { case TGSI_PROPERTY_GS_INPUT_PRIM: case TGSI_PROPERTY_GS_OUTPUT_PRIM: if (!parse_primitive(&ctx->cur, &values[0] )) { report_error( ctx, "Unknown primitive name as property!" ); return FALSE; } if (property_name == TGSI_PROPERTY_GS_INPUT_PRIM && ctx->processor == TGSI_PROCESSOR_GEOMETRY) { ctx->implied_array_size = u_vertices_per_prim(values[0]); } break; case TGSI_PROPERTY_FS_COORD_ORIGIN: if (!parse_fs_coord_origin(&ctx->cur, &values[0] )) { report_error( ctx, "Unknown coord origin as property: must be UPPER_LEFT or LOWER_LEFT!" ); return FALSE; } break; case TGSI_PROPERTY_FS_COORD_PIXEL_CENTER: if (!parse_fs_coord_pixel_center(&ctx->cur, &values[0] )) { report_error( ctx, "Unknown coord pixel center as property: must be HALF_INTEGER or INTEGER!" ); return FALSE; } break; case TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS: default: if (!parse_uint(&ctx->cur, &values[0] )) { report_error( ctx, "Expected unsigned integer as property!" ); return FALSE; } } prop = tgsi_default_full_property(); prop.Property.PropertyName = property_name; prop.Property.NrTokens += 1; prop.u[0].Data = values[0]; advance = tgsi_build_full_property( &prop, ctx->tokens_cur, ctx->header, (uint) (ctx->tokens_end - ctx->tokens_cur) ); if (advance == 0) return FALSE; ctx->tokens_cur += advance; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,766
parse_register_bracket( struct translate_ctx *ctx, struct parsed_bracket *brackets) { const char *cur; uint uindex; memset(brackets, 0, sizeof(struct parsed_bracket)); eat_opt_white( &ctx->cur ); cur = ctx->cur; if (parse_file( &cur, &brackets->ind_file )) { if (!parse_register_1d( ctx, &brackets->ind_file, &brackets->ind_index )) return FALSE; eat_opt_white( &ctx->cur ); if (*ctx->cur == '.') { ctx->cur++; eat_opt_white(&ctx->cur); switch (uprcase(*ctx->cur)) { case 'X': brackets->ind_comp = TGSI_SWIZZLE_X; break; case 'Y': brackets->ind_comp = TGSI_SWIZZLE_Y; break; case 'Z': brackets->ind_comp = TGSI_SWIZZLE_Z; break; case 'W': brackets->ind_comp = TGSI_SWIZZLE_W; break; default: report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'"); return FALSE; } ctx->cur++; eat_opt_white(&ctx->cur); } if (*ctx->cur == '+' || *ctx->cur == '-') parse_int( &ctx->cur, &brackets->index ); else brackets->index = 0; } else { if (!parse_uint( &ctx->cur, &uindex )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } brackets->index = (int) uindex; brackets->ind_file = TGSI_FILE_NULL; brackets->ind_index = 0; } eat_opt_white( &ctx->cur ); if (*ctx->cur != ']') { report_error( ctx, "Expected `]'" ); return FALSE; } ctx->cur++; if (*ctx->cur == '(') { ctx->cur++; eat_opt_white( &ctx->cur ); if (!parse_uint( &ctx->cur, &brackets->ind_array )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } eat_opt_white( &ctx->cur ); if (*ctx->cur != ')') { report_error( ctx, "Expected `)'" ); return FALSE; } ctx->cur++; } return TRUE; }
DoS Overflow
0
parse_register_bracket( struct translate_ctx *ctx, struct parsed_bracket *brackets) { const char *cur; uint uindex; memset(brackets, 0, sizeof(struct parsed_bracket)); eat_opt_white( &ctx->cur ); cur = ctx->cur; if (parse_file( &cur, &brackets->ind_file )) { if (!parse_register_1d( ctx, &brackets->ind_file, &brackets->ind_index )) return FALSE; eat_opt_white( &ctx->cur ); if (*ctx->cur == '.') { ctx->cur++; eat_opt_white(&ctx->cur); switch (uprcase(*ctx->cur)) { case 'X': brackets->ind_comp = TGSI_SWIZZLE_X; break; case 'Y': brackets->ind_comp = TGSI_SWIZZLE_Y; break; case 'Z': brackets->ind_comp = TGSI_SWIZZLE_Z; break; case 'W': brackets->ind_comp = TGSI_SWIZZLE_W; break; default: report_error(ctx, "Expected indirect register swizzle component `x', `y', `z' or `w'"); return FALSE; } ctx->cur++; eat_opt_white(&ctx->cur); } if (*ctx->cur == '+' || *ctx->cur == '-') parse_int( &ctx->cur, &brackets->index ); else brackets->index = 0; } else { if (!parse_uint( &ctx->cur, &uindex )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } brackets->index = (int) uindex; brackets->ind_file = TGSI_FILE_NULL; brackets->ind_index = 0; } eat_opt_white( &ctx->cur ); if (*ctx->cur != ']') { report_error( ctx, "Expected `]'" ); return FALSE; } ctx->cur++; if (*ctx->cur == '(') { ctx->cur++; eat_opt_white( &ctx->cur ); if (!parse_uint( &ctx->cur, &brackets->ind_array )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } eat_opt_white( &ctx->cur ); if (*ctx->cur != ')') { report_error( ctx, "Expected `)'" ); return FALSE; } ctx->cur++; } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,767
parse_register_dcl( struct translate_ctx *ctx, uint *file, struct parsed_dcl_bracket *brackets, int *num_brackets) { const char *cur; *num_brackets = 0; if (!parse_register_file_bracket( ctx, file )) return FALSE; if (!parse_register_dcl_bracket( ctx, &brackets[0] )) return FALSE; *num_brackets = 1; cur = ctx->cur; eat_opt_white( &cur ); if (cur[0] == '[') { bool is_in = *file == TGSI_FILE_INPUT; bool is_out = *file == TGSI_FILE_OUTPUT; ++cur; ctx->cur = cur; if (!parse_register_dcl_bracket( ctx, &brackets[1] )) return FALSE; /* for geometry shader we don't really care about * the first brackets it's always the size of the * input primitive. so we want to declare just * the index relevant to the semantics which is in * the second bracket */ /* tessellation has similar constraints to geometry shader */ if ((ctx->processor == TGSI_PROCESSOR_GEOMETRY && is_in) || (ctx->processor == TGSI_PROCESSOR_TESS_EVAL && is_in) || (ctx->processor == TGSI_PROCESSOR_TESS_CTRL && (is_in || is_out))) { brackets[0] = brackets[1]; *num_brackets = 1; } else { *num_brackets = 2; } } return TRUE; }
DoS Overflow
0
parse_register_dcl( struct translate_ctx *ctx, uint *file, struct parsed_dcl_bracket *brackets, int *num_brackets) { const char *cur; *num_brackets = 0; if (!parse_register_file_bracket( ctx, file )) return FALSE; if (!parse_register_dcl_bracket( ctx, &brackets[0] )) return FALSE; *num_brackets = 1; cur = ctx->cur; eat_opt_white( &cur ); if (cur[0] == '[') { bool is_in = *file == TGSI_FILE_INPUT; bool is_out = *file == TGSI_FILE_OUTPUT; ++cur; ctx->cur = cur; if (!parse_register_dcl_bracket( ctx, &brackets[1] )) return FALSE; /* for geometry shader we don't really care about * the first brackets it's always the size of the * input primitive. so we want to declare just * the index relevant to the semantics which is in * the second bracket */ /* tessellation has similar constraints to geometry shader */ if ((ctx->processor == TGSI_PROCESSOR_GEOMETRY && is_in) || (ctx->processor == TGSI_PROCESSOR_TESS_EVAL && is_in) || (ctx->processor == TGSI_PROCESSOR_TESS_CTRL && (is_in || is_out))) { brackets[0] = brackets[1]; *num_brackets = 1; } else { *num_brackets = 2; } } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,768
parse_register_dst( struct translate_ctx *ctx, uint *file, struct parsed_bracket *brackets) { brackets->ind_comp = TGSI_SWIZZLE_X; if (!parse_register_file_bracket( ctx, file )) return FALSE; if (!parse_register_bracket( ctx, brackets )) return FALSE; return TRUE; }
DoS Overflow
0
parse_register_dst( struct translate_ctx *ctx, uint *file, struct parsed_bracket *brackets) { brackets->ind_comp = TGSI_SWIZZLE_X; if (!parse_register_file_bracket( ctx, file )) return FALSE; if (!parse_register_bracket( ctx, brackets )) return FALSE; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,769
parse_register_file_bracket_index( struct translate_ctx *ctx, uint *file, int *index ) { uint uindex; if (!parse_register_file_bracket( ctx, file )) return FALSE; eat_opt_white( &ctx->cur ); if (!parse_uint( &ctx->cur, &uindex )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } *index = (int) uindex; return TRUE; }
DoS Overflow
0
parse_register_file_bracket_index( struct translate_ctx *ctx, uint *file, int *index ) { uint uindex; if (!parse_register_file_bracket( ctx, file )) return FALSE; eat_opt_white( &ctx->cur ); if (!parse_uint( &ctx->cur, &uindex )) { report_error( ctx, "Expected literal unsigned integer" ); return FALSE; } *index = (int) uindex; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,770
parse_register_src( struct translate_ctx *ctx, uint *file, struct parsed_bracket *brackets) { brackets->ind_comp = TGSI_SWIZZLE_X; if (!parse_register_file_bracket( ctx, file )) return FALSE; if (!parse_register_bracket( ctx, brackets )) return FALSE; return TRUE; }
DoS Overflow
0
parse_register_src( struct translate_ctx *ctx, uint *file, struct parsed_bracket *brackets) { brackets->ind_comp = TGSI_SWIZZLE_X; if (!parse_register_file_bracket( ctx, file )) return FALSE; if (!parse_register_bracket( ctx, brackets )) return FALSE; return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,771
parse_src_operand( struct translate_ctx *ctx, struct tgsi_full_src_register *src ) { uint file; uint swizzle[4]; boolean parsed_swizzle; struct parsed_bracket bracket[2]; int parsed_opt_brackets; if (*ctx->cur == '-') { ctx->cur++; eat_opt_white( &ctx->cur ); src->Register.Negate = 1; } if (*ctx->cur == '|') { ctx->cur++; eat_opt_white( &ctx->cur ); src->Register.Absolute = 1; } if (!parse_register_src(ctx, &file, &bracket[0])) return FALSE; if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets)) return FALSE; src->Register.File = file; if (parsed_opt_brackets) { src->Register.Dimension = 1; src->Dimension.Indirect = 0; src->Dimension.Dimension = 0; src->Dimension.Index = bracket[0].index; if (bracket[0].ind_file != TGSI_FILE_NULL) { src->Dimension.Indirect = 1; src->DimIndirect.File = bracket[0].ind_file; src->DimIndirect.Index = bracket[0].ind_index; src->DimIndirect.Swizzle = bracket[0].ind_comp; src->DimIndirect.ArrayID = bracket[0].ind_array; } bracket[0] = bracket[1]; } src->Register.Index = bracket[0].index; if (bracket[0].ind_file != TGSI_FILE_NULL) { src->Register.Indirect = 1; src->Indirect.File = bracket[0].ind_file; src->Indirect.Index = bracket[0].ind_index; src->Indirect.Swizzle = bracket[0].ind_comp; src->Indirect.ArrayID = bracket[0].ind_array; } /* Parse optional swizzle. */ if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, 4 )) { if (parsed_swizzle) { src->Register.SwizzleX = swizzle[0]; src->Register.SwizzleY = swizzle[1]; src->Register.SwizzleZ = swizzle[2]; src->Register.SwizzleW = swizzle[3]; } } if (src->Register.Absolute) { eat_opt_white( &ctx->cur ); if (*ctx->cur != '|') { report_error( ctx, "Expected `|'" ); return FALSE; } ctx->cur++; } return TRUE; }
DoS Overflow
0
parse_src_operand( struct translate_ctx *ctx, struct tgsi_full_src_register *src ) { uint file; uint swizzle[4]; boolean parsed_swizzle; struct parsed_bracket bracket[2]; int parsed_opt_brackets; if (*ctx->cur == '-') { ctx->cur++; eat_opt_white( &ctx->cur ); src->Register.Negate = 1; } if (*ctx->cur == '|') { ctx->cur++; eat_opt_white( &ctx->cur ); src->Register.Absolute = 1; } if (!parse_register_src(ctx, &file, &bracket[0])) return FALSE; if (!parse_opt_register_src_bracket(ctx, &bracket[1], &parsed_opt_brackets)) return FALSE; src->Register.File = file; if (parsed_opt_brackets) { src->Register.Dimension = 1; src->Dimension.Indirect = 0; src->Dimension.Dimension = 0; src->Dimension.Index = bracket[0].index; if (bracket[0].ind_file != TGSI_FILE_NULL) { src->Dimension.Indirect = 1; src->DimIndirect.File = bracket[0].ind_file; src->DimIndirect.Index = bracket[0].ind_index; src->DimIndirect.Swizzle = bracket[0].ind_comp; src->DimIndirect.ArrayID = bracket[0].ind_array; } bracket[0] = bracket[1]; } src->Register.Index = bracket[0].index; if (bracket[0].ind_file != TGSI_FILE_NULL) { src->Register.Indirect = 1; src->Indirect.File = bracket[0].ind_file; src->Indirect.Index = bracket[0].ind_index; src->Indirect.Swizzle = bracket[0].ind_comp; src->Indirect.ArrayID = bracket[0].ind_array; } /* Parse optional swizzle. */ if (parse_optional_swizzle( ctx, swizzle, &parsed_swizzle, 4 )) { if (parsed_swizzle) { src->Register.SwizzleX = swizzle[0]; src->Register.SwizzleY = swizzle[1]; src->Register.SwizzleZ = swizzle[2]; src->Register.SwizzleW = swizzle[3]; } } if (src->Register.Absolute) { eat_opt_white( &ctx->cur ); if (*ctx->cur != '|') { report_error( ctx, "Expected `|'" ); return FALSE; } ctx->cur++; } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,772
static void report_error(struct translate_ctx *ctx, const char *format, ...) { va_list args; int line = 1; int column = 1; const char *itr = ctx->text; debug_printf("\nTGSI asm error: "); va_start(args, format); _debug_vprintf(format, args); va_end(args); while (itr != ctx->cur) { if (*itr == '\n') { column = 1; ++line; } ++column; ++itr; } debug_printf(" [%d : %d] \n", line, column); }
DoS Overflow
0
static void report_error(struct translate_ctx *ctx, const char *format, ...) { va_list args; int line = 1; int column = 1; const char *itr = ctx->text; debug_printf("\nTGSI asm error: "); va_start(args, format); _debug_vprintf(format, args); va_end(args); while (itr != ctx->cur) { if (*itr == '\n') { column = 1; ++line; } ++column; ++itr; } debug_printf(" [%d : %d] \n", line, column); }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,773
tgsi_text_translate( const char *text, struct tgsi_token *tokens, uint num_tokens ) { struct translate_ctx ctx = {0}; ctx.text = text; ctx.cur = text; ctx.tokens = tokens; ctx.tokens_cur = tokens; ctx.tokens_end = tokens + num_tokens; if (!translate( &ctx )) return FALSE; return tgsi_sanity_check( tokens ); }
DoS Overflow
0
tgsi_text_translate( const char *text, struct tgsi_token *tokens, uint num_tokens ) { struct translate_ctx ctx = {0}; ctx.text = text; ctx.cur = text; ctx.tokens = tokens; ctx.tokens_cur = tokens; ctx.tokens_end = tokens + num_tokens; if (!translate( &ctx )) return FALSE; return tgsi_sanity_check( tokens ); }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,774
static boolean translate( struct translate_ctx *ctx ) { eat_opt_white( &ctx->cur ); if (!parse_header( ctx )) return FALSE; if (ctx->processor == TGSI_PROCESSOR_TESS_CTRL || ctx->processor == TGSI_PROCESSOR_TESS_EVAL) ctx->implied_array_size = 32; while (*ctx->cur != '\0') { uint label_val = 0; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (*ctx->cur == '\0') break; if (parse_label( ctx, &label_val )) { if (!parse_instruction( ctx, TRUE )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "DCL" )) { if (!parse_declaration( ctx )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "IMM" )) { if (!parse_immediate( ctx )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "PROPERTY" )) { if (!parse_property( ctx )) return FALSE; } else if (!parse_instruction( ctx, FALSE )) { return FALSE; } } return TRUE; }
DoS Overflow
0
static boolean translate( struct translate_ctx *ctx ) { eat_opt_white( &ctx->cur ); if (!parse_header( ctx )) return FALSE; if (ctx->processor == TGSI_PROCESSOR_TESS_CTRL || ctx->processor == TGSI_PROCESSOR_TESS_EVAL) ctx->implied_array_size = 32; while (*ctx->cur != '\0') { uint label_val = 0; if (!eat_white( &ctx->cur )) { report_error( ctx, "Syntax error" ); return FALSE; } if (*ctx->cur == '\0') break; if (parse_label( ctx, &label_val )) { if (!parse_instruction( ctx, TRUE )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "DCL" )) { if (!parse_declaration( ctx )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "IMM" )) { if (!parse_immediate( ctx )) return FALSE; } else if (str_match_nocase_whole( &ctx->cur, "PROPERTY" )) { if (!parse_property( ctx )) return FALSE; } else if (!parse_instruction( ctx, FALSE )) { return FALSE; } } return TRUE; }
@@ -1097,7 +1097,7 @@ parse_instruction( cur = ctx->cur; eat_opt_white( &cur ); - for (i = 0; inst.Instruction.Texture && *cur == ','; i++) { + for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) { cur++; eat_opt_white( &cur ); ctx->cur = cur;
CWE-119
null
null
7,775
static void virtio_gpu_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); vdc->realize = virtio_gpu_device_realize; vdc->unrealize = virtio_gpu_device_unrealize; vdc->get_config = virtio_gpu_get_config; vdc->set_config = virtio_gpu_set_config; vdc->get_features = virtio_gpu_get_features; vdc->set_features = virtio_gpu_set_features; vdc->reset = virtio_gpu_reset; dc->props = virtio_gpu_properties; dc->vmsd = &vmstate_virtio_gpu; }
DoS
0
static void virtio_gpu_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); vdc->realize = virtio_gpu_device_realize; vdc->unrealize = virtio_gpu_device_unrealize; vdc->get_config = virtio_gpu_get_config; vdc->set_config = virtio_gpu_set_config; vdc->get_features = virtio_gpu_get_features; vdc->set_features = virtio_gpu_set_features; vdc->reset = virtio_gpu_reset; dc->props = virtio_gpu_properties; dc->vmsd = &vmstate_virtio_gpu; }
@@ -714,6 +714,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g, return; } + if (res->iov) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov); if (ret != 0) { cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
CWE-772
null
null
7,776
static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(qdev); VirtIOGPU *g = VIRTIO_GPU(qdev); bool have_virgl; int i; if (g->conf.max_outputs > VIRTIO_GPU_MAX_SCANOUTS) { error_setg(errp, "invalid max_outputs > %d", VIRTIO_GPU_MAX_SCANOUTS); return; } g->config_size = sizeof(struct virtio_gpu_config); g->virtio_config.num_scanouts = g->conf.max_outputs; virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, g->config_size); g->req_state[0].width = 1024; g->req_state[0].height = 768; g->use_virgl_renderer = false; #if !defined(CONFIG_VIRGL) || defined(HOST_WORDS_BIGENDIAN) have_virgl = false; #else have_virgl = display_opengl; #endif if (!have_virgl) { g->conf.flags &= ~(1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED); } if (virtio_gpu_virgl_enabled(g->conf)) { /* use larger control queue in 3d mode */ g->ctrl_vq = virtio_add_queue(vdev, 256, virtio_gpu_handle_ctrl_cb); g->cursor_vq = virtio_add_queue(vdev, 16, virtio_gpu_handle_cursor_cb); g->virtio_config.num_capsets = 1; } else { g->ctrl_vq = virtio_add_queue(vdev, 64, virtio_gpu_handle_ctrl_cb); g->cursor_vq = virtio_add_queue(vdev, 16, virtio_gpu_handle_cursor_cb); } g->ctrl_bh = qemu_bh_new(virtio_gpu_ctrl_bh, g); g->cursor_bh = qemu_bh_new(virtio_gpu_cursor_bh, g); QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); QTAILQ_INIT(&g->fenceq); g->enabled_output_bitmask = 1; g->qdev = qdev; for (i = 0; i < g->conf.max_outputs; i++) { g->scanout[i].con = graphic_console_init(DEVICE(g), i, &virtio_gpu_ops, g); if (i > 0) { dpy_gfx_replace_surface(g->scanout[i].con, NULL); } } if (virtio_gpu_virgl_enabled(g->conf)) { error_setg(&g->migration_blocker, "virgl is not yet migratable"); migrate_add_blocker(g->migration_blocker); } }
DoS
0
static void virtio_gpu_device_realize(DeviceState *qdev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(qdev); VirtIOGPU *g = VIRTIO_GPU(qdev); bool have_virgl; int i; if (g->conf.max_outputs > VIRTIO_GPU_MAX_SCANOUTS) { error_setg(errp, "invalid max_outputs > %d", VIRTIO_GPU_MAX_SCANOUTS); return; } g->config_size = sizeof(struct virtio_gpu_config); g->virtio_config.num_scanouts = g->conf.max_outputs; virtio_init(VIRTIO_DEVICE(g), "virtio-gpu", VIRTIO_ID_GPU, g->config_size); g->req_state[0].width = 1024; g->req_state[0].height = 768; g->use_virgl_renderer = false; #if !defined(CONFIG_VIRGL) || defined(HOST_WORDS_BIGENDIAN) have_virgl = false; #else have_virgl = display_opengl; #endif if (!have_virgl) { g->conf.flags &= ~(1 << VIRTIO_GPU_FLAG_VIRGL_ENABLED); } if (virtio_gpu_virgl_enabled(g->conf)) { /* use larger control queue in 3d mode */ g->ctrl_vq = virtio_add_queue(vdev, 256, virtio_gpu_handle_ctrl_cb); g->cursor_vq = virtio_add_queue(vdev, 16, virtio_gpu_handle_cursor_cb); g->virtio_config.num_capsets = 1; } else { g->ctrl_vq = virtio_add_queue(vdev, 64, virtio_gpu_handle_ctrl_cb); g->cursor_vq = virtio_add_queue(vdev, 16, virtio_gpu_handle_cursor_cb); } g->ctrl_bh = qemu_bh_new(virtio_gpu_ctrl_bh, g); g->cursor_bh = qemu_bh_new(virtio_gpu_cursor_bh, g); QTAILQ_INIT(&g->reslist); QTAILQ_INIT(&g->cmdq); QTAILQ_INIT(&g->fenceq); g->enabled_output_bitmask = 1; g->qdev = qdev; for (i = 0; i < g->conf.max_outputs; i++) { g->scanout[i].con = graphic_console_init(DEVICE(g), i, &virtio_gpu_ops, g); if (i > 0) { dpy_gfx_replace_surface(g->scanout[i].con, NULL); } } if (virtio_gpu_virgl_enabled(g->conf)) { error_setg(&g->migration_blocker, "virgl is not yet migratable"); migrate_add_blocker(g->migration_blocker); } }
@@ -714,6 +714,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g, return; } + if (res->iov) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov); if (ret != 0) { cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
CWE-772
null
null
7,777
static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size) { VirtIOGPU *g = opaque; struct virtio_gpu_simple_resource *res; struct virtio_gpu_scanout *scanout; uint32_t resource_id, pformat; int i; resource_id = qemu_get_be32(f); while (resource_id != 0) { res = g_new0(struct virtio_gpu_simple_resource, 1); res->resource_id = resource_id; res->width = qemu_get_be32(f); res->height = qemu_get_be32(f); res->format = qemu_get_be32(f); res->iov_cnt = qemu_get_be32(f); /* allocate */ pformat = get_pixman_format(res->format); if (!pformat) { return -EINVAL; } res->image = pixman_image_create_bits(pformat, res->width, res->height, NULL, 0); if (!res->image) { return -EINVAL; } res->addrs = g_new(uint64_t, res->iov_cnt); res->iov = g_new(struct iovec, res->iov_cnt); /* read data */ for (i = 0; i < res->iov_cnt; i++) { res->addrs[i] = qemu_get_be64(f); res->iov[i].iov_len = qemu_get_be32(f); } qemu_get_buffer(f, (void *)pixman_image_get_data(res->image), pixman_image_get_stride(res->image) * res->height); /* restore mapping */ for (i = 0; i < res->iov_cnt; i++) { hwaddr len = res->iov[i].iov_len; res->iov[i].iov_base = cpu_physical_memory_map(res->addrs[i], &len, 1); if (!res->iov[i].iov_base || len != res->iov[i].iov_len) { return -EINVAL; } } QTAILQ_INSERT_HEAD(&g->reslist, res, next); resource_id = qemu_get_be32(f); } /* load & apply scanout state */ vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1); for (i = 0; i < g->conf.max_outputs; i++) { scanout = &g->scanout[i]; if (!scanout->resource_id) { continue; } res = virtio_gpu_find_resource(g, scanout->resource_id); if (!res) { return -EINVAL; } scanout->ds = qemu_create_displaysurface_pixman(res->image); if (!scanout->ds) { return -EINVAL; } dpy_gfx_replace_surface(scanout->con, scanout->ds); dpy_gfx_update(scanout->con, 0, 0, scanout->width, scanout->height); update_cursor(g, &scanout->cursor); res->scanout_bitmask |= (1 << i); } return 0; }
DoS
0
static int virtio_gpu_load(QEMUFile *f, void *opaque, size_t size) { VirtIOGPU *g = opaque; struct virtio_gpu_simple_resource *res; struct virtio_gpu_scanout *scanout; uint32_t resource_id, pformat; int i; resource_id = qemu_get_be32(f); while (resource_id != 0) { res = g_new0(struct virtio_gpu_simple_resource, 1); res->resource_id = resource_id; res->width = qemu_get_be32(f); res->height = qemu_get_be32(f); res->format = qemu_get_be32(f); res->iov_cnt = qemu_get_be32(f); /* allocate */ pformat = get_pixman_format(res->format); if (!pformat) { return -EINVAL; } res->image = pixman_image_create_bits(pformat, res->width, res->height, NULL, 0); if (!res->image) { return -EINVAL; } res->addrs = g_new(uint64_t, res->iov_cnt); res->iov = g_new(struct iovec, res->iov_cnt); /* read data */ for (i = 0; i < res->iov_cnt; i++) { res->addrs[i] = qemu_get_be64(f); res->iov[i].iov_len = qemu_get_be32(f); } qemu_get_buffer(f, (void *)pixman_image_get_data(res->image), pixman_image_get_stride(res->image) * res->height); /* restore mapping */ for (i = 0; i < res->iov_cnt; i++) { hwaddr len = res->iov[i].iov_len; res->iov[i].iov_base = cpu_physical_memory_map(res->addrs[i], &len, 1); if (!res->iov[i].iov_base || len != res->iov[i].iov_len) { return -EINVAL; } } QTAILQ_INSERT_HEAD(&g->reslist, res, next); resource_id = qemu_get_be32(f); } /* load & apply scanout state */ vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1); for (i = 0; i < g->conf.max_outputs; i++) { scanout = &g->scanout[i]; if (!scanout->resource_id) { continue; } res = virtio_gpu_find_resource(g, scanout->resource_id); if (!res) { return -EINVAL; } scanout->ds = qemu_create_displaysurface_pixman(res->image); if (!scanout->ds) { return -EINVAL; } dpy_gfx_replace_surface(scanout->con, scanout->ds); dpy_gfx_update(scanout->con, 0, 0, scanout->width, scanout->height); update_cursor(g, &scanout->cursor); res->scanout_bitmask |= (1 << i); } return 0; }
@@ -714,6 +714,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g, return; } + if (res->iov) { + cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; + return; + } + ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov); if (ret != 0) { cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
CWE-772
null
null
7,778
static void virgl_cmd_context_destroy(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_ctx_destroy cd; VIRTIO_GPU_FILL_CMD(cd); trace_virtio_gpu_cmd_ctx_destroy(cd.hdr.ctx_id); virgl_renderer_context_destroy(cd.hdr.ctx_id); }
DoS
0
static void virgl_cmd_context_destroy(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_ctx_destroy cd; VIRTIO_GPU_FILL_CMD(cd); trace_virtio_gpu_cmd_ctx_destroy(cd.hdr.ctx_id); virgl_renderer_context_destroy(cd.hdr.ctx_id); }
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, - res_iovs, att_rb.nr_entries); + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, + res_iovs, att_rb.nr_entries); + + if (ret != 0) + virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries); } static void virgl_resource_detach_backing(VirtIOGPU *g,
CWE-772
null
null
7,779
static void virgl_cmd_create_resource_3d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_create_3d c3d; struct virgl_renderer_resource_create_args args; VIRTIO_GPU_FILL_CMD(c3d); trace_virtio_gpu_cmd_res_create_3d(c3d.resource_id, c3d.format, c3d.width, c3d.height, c3d.depth); args.handle = c3d.resource_id; args.target = c3d.target; args.format = c3d.format; args.bind = c3d.bind; args.width = c3d.width; args.height = c3d.height; args.depth = c3d.depth; args.array_size = c3d.array_size; args.last_level = c3d.last_level; args.nr_samples = c3d.nr_samples; args.flags = c3d.flags; virgl_renderer_resource_create(&args, NULL, 0); }
DoS
0
static void virgl_cmd_create_resource_3d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_create_3d c3d; struct virgl_renderer_resource_create_args args; VIRTIO_GPU_FILL_CMD(c3d); trace_virtio_gpu_cmd_res_create_3d(c3d.resource_id, c3d.format, c3d.width, c3d.height, c3d.depth); args.handle = c3d.resource_id; args.target = c3d.target; args.format = c3d.format; args.bind = c3d.bind; args.width = c3d.width; args.height = c3d.height; args.depth = c3d.depth; args.array_size = c3d.array_size; args.last_level = c3d.last_level; args.nr_samples = c3d.nr_samples; args.flags = c3d.flags; virgl_renderer_resource_create(&args, NULL, 0); }
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, - res_iovs, att_rb.nr_entries); + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, + res_iovs, att_rb.nr_entries); + + if (ret != 0) + virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries); } static void virgl_resource_detach_backing(VirtIOGPU *g,
CWE-772
null
null
7,780
static void virgl_cmd_resource_flush(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_flush rf; int i; VIRTIO_GPU_FILL_CMD(rf); trace_virtio_gpu_cmd_res_flush(rf.resource_id, rf.r.width, rf.r.height, rf.r.x, rf.r.y); for (i = 0; i < g->conf.max_outputs; i++) { if (g->scanout[i].resource_id != rf.resource_id) { continue; } virtio_gpu_rect_update(g, i, rf.r.x, rf.r.y, rf.r.width, rf.r.height); } }
DoS
0
static void virgl_cmd_resource_flush(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_flush rf; int i; VIRTIO_GPU_FILL_CMD(rf); trace_virtio_gpu_cmd_res_flush(rf.resource_id, rf.r.width, rf.r.height, rf.r.x, rf.r.y); for (i = 0; i < g->conf.max_outputs; i++) { if (g->scanout[i].resource_id != rf.resource_id) { continue; } virtio_gpu_rect_update(g, i, rf.r.x, rf.r.y, rf.r.width, rf.r.height); } }
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, - res_iovs, att_rb.nr_entries); + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, + res_iovs, att_rb.nr_entries); + + if (ret != 0) + virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries); } static void virgl_resource_detach_backing(VirtIOGPU *g,
CWE-772
null
null
7,781
static void virgl_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_unref unref; VIRTIO_GPU_FILL_CMD(unref); trace_virtio_gpu_cmd_res_unref(unref.resource_id); virgl_renderer_resource_unref(unref.resource_id); }
DoS
0
static void virgl_cmd_resource_unref(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_resource_unref unref; VIRTIO_GPU_FILL_CMD(unref); trace_virtio_gpu_cmd_res_unref(unref.resource_id); virgl_renderer_resource_unref(unref.resource_id); }
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, - res_iovs, att_rb.nr_entries); + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, + res_iovs, att_rb.nr_entries); + + if (ret != 0) + virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries); } static void virgl_resource_detach_backing(VirtIOGPU *g,
CWE-772
null
null
7,782
static void virgl_cmd_set_scanout(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_set_scanout ss; struct virgl_renderer_resource_info info; int ret; VIRTIO_GPU_FILL_CMD(ss); trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id, ss.r.width, ss.r.height, ss.r.x, ss.r.y); if (ss.scanout_id >= g->conf.max_outputs) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d", __func__, ss.scanout_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; return; } g->enable = 1; memset(&info, 0, sizeof(info)); if (ss.resource_id && ss.r.width && ss.r.height) { ret = virgl_renderer_resource_get_info(ss.resource_id, &info); if (ret == -1) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal resource specified %d\n", __func__, ss.resource_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; return; } qemu_console_resize(g->scanout[ss.scanout_id].con, ss.r.width, ss.r.height); virgl_renderer_force_ctx_0(); dpy_gl_scanout(g->scanout[ss.scanout_id].con, info.tex_id, info.flags & 1 /* FIXME: Y_0_TOP */, info.width, info.height, ss.r.x, ss.r.y, ss.r.width, ss.r.height); } else { if (ss.scanout_id != 0) { dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, NULL); } dpy_gl_scanout(g->scanout[ss.scanout_id].con, 0, false, 0, 0, 0, 0, 0, 0); } g->scanout[ss.scanout_id].resource_id = ss.resource_id; }
DoS
0
static void virgl_cmd_set_scanout(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_set_scanout ss; struct virgl_renderer_resource_info info; int ret; VIRTIO_GPU_FILL_CMD(ss); trace_virtio_gpu_cmd_set_scanout(ss.scanout_id, ss.resource_id, ss.r.width, ss.r.height, ss.r.x, ss.r.y); if (ss.scanout_id >= g->conf.max_outputs) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal scanout id specified %d", __func__, ss.scanout_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_SCANOUT_ID; return; } g->enable = 1; memset(&info, 0, sizeof(info)); if (ss.resource_id && ss.r.width && ss.r.height) { ret = virgl_renderer_resource_get_info(ss.resource_id, &info); if (ret == -1) { qemu_log_mask(LOG_GUEST_ERROR, "%s: illegal resource specified %d\n", __func__, ss.resource_id); cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_RESOURCE_ID; return; } qemu_console_resize(g->scanout[ss.scanout_id].con, ss.r.width, ss.r.height); virgl_renderer_force_ctx_0(); dpy_gl_scanout(g->scanout[ss.scanout_id].con, info.tex_id, info.flags & 1 /* FIXME: Y_0_TOP */, info.width, info.height, ss.r.x, ss.r.y, ss.r.width, ss.r.height); } else { if (ss.scanout_id != 0) { dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, NULL); } dpy_gl_scanout(g->scanout[ss.scanout_id].con, 0, false, 0, 0, 0, 0, 0, 0); } g->scanout[ss.scanout_id].resource_id = ss.resource_id; }
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, - res_iovs, att_rb.nr_entries); + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, + res_iovs, att_rb.nr_entries); + + if (ret != 0) + virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries); } static void virgl_resource_detach_backing(VirtIOGPU *g,
CWE-772
null
null
7,783
static void virgl_cmd_transfer_to_host_2d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_transfer_to_host_2d t2d; struct virtio_gpu_box box; VIRTIO_GPU_FILL_CMD(t2d); trace_virtio_gpu_cmd_res_xfer_toh_2d(t2d.resource_id); box.x = t2d.r.x; box.y = t2d.r.y; box.z = 0; box.w = t2d.r.width; box.h = t2d.r.height; box.d = 1; virgl_renderer_transfer_write_iov(t2d.resource_id, 0, 0, 0, 0, (struct virgl_box *)&box, t2d.offset, NULL, 0); }
DoS
0
static void virgl_cmd_transfer_to_host_2d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_transfer_to_host_2d t2d; struct virtio_gpu_box box; VIRTIO_GPU_FILL_CMD(t2d); trace_virtio_gpu_cmd_res_xfer_toh_2d(t2d.resource_id); box.x = t2d.r.x; box.y = t2d.r.y; box.z = 0; box.w = t2d.r.width; box.h = t2d.r.height; box.d = 1; virgl_renderer_transfer_write_iov(t2d.resource_id, 0, 0, 0, 0, (struct virgl_box *)&box, t2d.offset, NULL, 0); }
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, - res_iovs, att_rb.nr_entries); + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, + res_iovs, att_rb.nr_entries); + + if (ret != 0) + virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries); } static void virgl_resource_detach_backing(VirtIOGPU *g,
CWE-772
null
null
7,784
static void virgl_cmd_transfer_to_host_3d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_transfer_host_3d t3d; VIRTIO_GPU_FILL_CMD(t3d); trace_virtio_gpu_cmd_res_xfer_toh_3d(t3d.resource_id); virgl_renderer_transfer_write_iov(t3d.resource_id, t3d.hdr.ctx_id, t3d.level, t3d.stride, t3d.layer_stride, (struct virgl_box *)&t3d.box, t3d.offset, NULL, 0); }
DoS
0
static void virgl_cmd_transfer_to_host_3d(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_transfer_host_3d t3d; VIRTIO_GPU_FILL_CMD(t3d); trace_virtio_gpu_cmd_res_xfer_toh_3d(t3d.resource_id); virgl_renderer_transfer_write_iov(t3d.resource_id, t3d.hdr.ctx_id, t3d.level, t3d.stride, t3d.layer_stride, (struct virgl_box *)&t3d.box, t3d.offset, NULL, 0); }
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g, return; } - virgl_renderer_resource_attach_iov(att_rb.resource_id, - res_iovs, att_rb.nr_entries); + ret = virgl_renderer_resource_attach_iov(att_rb.resource_id, + res_iovs, att_rb.nr_entries); + + if (ret != 0) + virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries); } static void virgl_resource_detach_backing(VirtIOGPU *g,
CWE-772
null
null
7,785
static void __http_protocol_init(void) { acl_register_keywords(&acl_kws); sample_register_fetches(&sample_fetch_keywords); sample_register_convs(&sample_conv_kws); }
DoS Overflow
0
static void __http_protocol_init(void) { acl_register_keywords(&acl_kws); sample_register_fetches(&sample_fetch_keywords); sample_register_convs(&sample_conv_kws); }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,786
struct http_req_action_kw *action_http_req_custom(const char *kw) { if (!LIST_ISEMPTY(&http_req_keywords.list)) { struct http_req_action_kw_list *kw_list; int i; list_for_each_entry(kw_list, &http_req_keywords.list, list) { for (i = 0; kw_list->kw[i].kw != NULL; i++) { if (!strcmp(kw, kw_list->kw[i].kw)) return &kw_list->kw[i]; } } } return NULL; }
DoS Overflow
0
struct http_req_action_kw *action_http_req_custom(const char *kw) { if (!LIST_ISEMPTY(&http_req_keywords.list)) { struct http_req_action_kw_list *kw_list; int i; list_for_each_entry(kw_list, &http_req_keywords.list, list) { for (i = 0; kw_list->kw[i].kw != NULL; i++) { if (!strcmp(kw, kw_list->kw[i].kw)) return &kw_list->kw[i]; } } } return NULL; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,787
int apply_filter_to_req_headers(struct session *s, struct channel *req, struct hdr_exp *exp) { char *cur_ptr, *cur_end, *cur_next; int cur_idx, old_idx, last_hdr; struct http_txn *txn = &s->txn; struct hdr_idx_elem *cur_hdr; int delta; last_hdr = 0; cur_next = req->buf->p + hdr_idx_first_pos(&txn->hdr_idx); old_idx = 0; while (!last_hdr) { if (unlikely(txn->flags & (TX_CLDENY | TX_CLTARPIT))) return 1; else if (unlikely(txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT)) return 0; cur_idx = txn->hdr_idx.v[old_idx].next; if (!cur_idx) break; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* Now we have one header between cur_ptr and cur_end, * and the next header starts at cur_next. */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch)) { switch (exp->action) { case ACT_SETBE: /* It is not possible to jump a second time. * FIXME: should we return an HTTP/500 here so that * the admin knows there's a problem ? */ if (s->be != s->fe) break; /* Swithing Proxy */ session_set_backend(s, (struct proxy *)exp->replace); last_hdr = 1; break; case ACT_ALLOW: txn->flags |= TX_CLALLOW; last_hdr = 1; break; case ACT_DENY: txn->flags |= TX_CLDENY; last_hdr = 1; break; case ACT_TARPIT: txn->flags |= TX_CLTARPIT; last_hdr = 1; break; case ACT_REPLACE: trash.len = exp_replace(trash.str, trash.size, cur_ptr, exp->replace, pmatch); if (trash.len < 0) return -1; delta = buffer_replace2(req->buf, cur_ptr, cur_end, trash.str, trash.len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ cur_end += delta; cur_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); break; case ACT_REMOVE: delta = buffer_replace2(req->buf, cur_ptr, cur_next, NULL, 0); cur_next += delta; http_msg_move_end(&txn->req, delta); txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_end = NULL; /* null-term has been rewritten */ cur_idx = old_idx; break; } } /* keep the link from this header to next one in case of later * removal of next header. */ old_idx = cur_idx; } return 0; }
DoS Overflow
0
int apply_filter_to_req_headers(struct session *s, struct channel *req, struct hdr_exp *exp) { char *cur_ptr, *cur_end, *cur_next; int cur_idx, old_idx, last_hdr; struct http_txn *txn = &s->txn; struct hdr_idx_elem *cur_hdr; int delta; last_hdr = 0; cur_next = req->buf->p + hdr_idx_first_pos(&txn->hdr_idx); old_idx = 0; while (!last_hdr) { if (unlikely(txn->flags & (TX_CLDENY | TX_CLTARPIT))) return 1; else if (unlikely(txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT)) return 0; cur_idx = txn->hdr_idx.v[old_idx].next; if (!cur_idx) break; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* Now we have one header between cur_ptr and cur_end, * and the next header starts at cur_next. */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch)) { switch (exp->action) { case ACT_SETBE: /* It is not possible to jump a second time. * FIXME: should we return an HTTP/500 here so that * the admin knows there's a problem ? */ if (s->be != s->fe) break; /* Swithing Proxy */ session_set_backend(s, (struct proxy *)exp->replace); last_hdr = 1; break; case ACT_ALLOW: txn->flags |= TX_CLALLOW; last_hdr = 1; break; case ACT_DENY: txn->flags |= TX_CLDENY; last_hdr = 1; break; case ACT_TARPIT: txn->flags |= TX_CLTARPIT; last_hdr = 1; break; case ACT_REPLACE: trash.len = exp_replace(trash.str, trash.size, cur_ptr, exp->replace, pmatch); if (trash.len < 0) return -1; delta = buffer_replace2(req->buf, cur_ptr, cur_end, trash.str, trash.len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ cur_end += delta; cur_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->req, delta); break; case ACT_REMOVE: delta = buffer_replace2(req->buf, cur_ptr, cur_next, NULL, 0); cur_next += delta; http_msg_move_end(&txn->req, delta); txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_end = NULL; /* null-term has been rewritten */ cur_idx = old_idx; break; } } /* keep the link from this header to next one in case of later * removal of next header. */ old_idx = cur_idx; } return 0; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,788
int apply_filter_to_resp_headers(struct session *s, struct channel *rtr, struct hdr_exp *exp) { char *cur_ptr, *cur_end, *cur_next; int cur_idx, old_idx, last_hdr; struct http_txn *txn = &s->txn; struct hdr_idx_elem *cur_hdr; int delta; last_hdr = 0; cur_next = rtr->buf->p + hdr_idx_first_pos(&txn->hdr_idx); old_idx = 0; while (!last_hdr) { if (unlikely(txn->flags & TX_SVDENY)) return 1; else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; cur_idx = txn->hdr_idx.v[old_idx].next; if (!cur_idx) break; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* Now we have one header between cur_ptr and cur_end, * and the next header starts at cur_next. */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_SVALLOW; last_hdr = 1; break; case ACT_DENY: txn->flags |= TX_SVDENY; last_hdr = 1; break; case ACT_REPLACE: trash.len = exp_replace(trash.str, trash.size, cur_ptr, exp->replace, pmatch); if (trash.len < 0) return -1; delta = buffer_replace2(rtr->buf, cur_ptr, cur_end, trash.str, trash.len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ cur_end += delta; cur_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->rsp, delta); break; case ACT_REMOVE: delta = buffer_replace2(rtr->buf, cur_ptr, cur_next, NULL, 0); cur_next += delta; http_msg_move_end(&txn->rsp, delta); txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_end = NULL; /* null-term has been rewritten */ cur_idx = old_idx; break; } } /* keep the link from this header to next one in case of later * removal of next header. */ old_idx = cur_idx; } return 0; }
DoS Overflow
0
int apply_filter_to_resp_headers(struct session *s, struct channel *rtr, struct hdr_exp *exp) { char *cur_ptr, *cur_end, *cur_next; int cur_idx, old_idx, last_hdr; struct http_txn *txn = &s->txn; struct hdr_idx_elem *cur_hdr; int delta; last_hdr = 0; cur_next = rtr->buf->p + hdr_idx_first_pos(&txn->hdr_idx); old_idx = 0; while (!last_hdr) { if (unlikely(txn->flags & TX_SVDENY)) return 1; else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; cur_idx = txn->hdr_idx.v[old_idx].next; if (!cur_idx) break; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* Now we have one header between cur_ptr and cur_end, * and the next header starts at cur_next. */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_SVALLOW; last_hdr = 1; break; case ACT_DENY: txn->flags |= TX_SVDENY; last_hdr = 1; break; case ACT_REPLACE: trash.len = exp_replace(trash.str, trash.size, cur_ptr, exp->replace, pmatch); if (trash.len < 0) return -1; delta = buffer_replace2(rtr->buf, cur_ptr, cur_end, trash.str, trash.len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ cur_end += delta; cur_next += delta; cur_hdr->len += delta; http_msg_move_end(&txn->rsp, delta); break; case ACT_REMOVE: delta = buffer_replace2(rtr->buf, cur_ptr, cur_next, NULL, 0); cur_next += delta; http_msg_move_end(&txn->rsp, delta); txn->hdr_idx.v[old_idx].next = cur_hdr->next; txn->hdr_idx.used--; cur_hdr->len = 0; cur_end = NULL; /* null-term has been rewritten */ cur_idx = old_idx; break; } } /* keep the link from this header to next one in case of later * removal of next header. */ old_idx = cur_idx; } return 0; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,789
int apply_filter_to_sts_line(struct session *s, struct channel *rtr, struct hdr_exp *exp) { char *cur_ptr, *cur_end; int done; struct http_txn *txn = &s->txn; int delta; if (unlikely(txn->flags & TX_SVDENY)) return 1; else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; else if (exp->action == ACT_REMOVE) return 0; done = 0; cur_ptr = rtr->buf->p; cur_end = cur_ptr + txn->rsp.sl.st.l; /* Now we have the status line between cur_ptr and cur_end */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_SVALLOW; done = 1; break; case ACT_DENY: txn->flags |= TX_SVDENY; done = 1; break; case ACT_REPLACE: trash.len = exp_replace(trash.str, trash.size, cur_ptr, exp->replace, pmatch); if (trash.len < 0) return -1; delta = buffer_replace2(rtr->buf, cur_ptr, cur_end, trash.str, trash.len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ http_msg_move_end(&txn->rsp, delta); cur_end += delta; cur_end = (char *)http_parse_stsline(&txn->rsp, HTTP_MSG_RPVER, cur_ptr, cur_end + 1, NULL, NULL); if (unlikely(!cur_end)) return -1; /* we have a full respnse and we know that we have either a CR * or an LF at <ptr>. */ txn->status = strl2ui(rtr->buf->p + txn->rsp.sl.st.c, txn->rsp.sl.st.c_l); hdr_idx_set_start(&txn->hdr_idx, txn->rsp.sl.st.l, *cur_end == '\r'); /* there is no point trying this regex on headers */ return 1; } } return done; }
DoS Overflow
0
int apply_filter_to_sts_line(struct session *s, struct channel *rtr, struct hdr_exp *exp) { char *cur_ptr, *cur_end; int done; struct http_txn *txn = &s->txn; int delta; if (unlikely(txn->flags & TX_SVDENY)) return 1; else if (unlikely(txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY)) return 0; else if (exp->action == ACT_REMOVE) return 0; done = 0; cur_ptr = rtr->buf->p; cur_end = cur_ptr + txn->rsp.sl.st.l; /* Now we have the status line between cur_ptr and cur_end */ if (regex_exec_match2(exp->preg, cur_ptr, cur_end-cur_ptr, MAX_MATCH, pmatch)) { switch (exp->action) { case ACT_ALLOW: txn->flags |= TX_SVALLOW; done = 1; break; case ACT_DENY: txn->flags |= TX_SVDENY; done = 1; break; case ACT_REPLACE: trash.len = exp_replace(trash.str, trash.size, cur_ptr, exp->replace, pmatch); if (trash.len < 0) return -1; delta = buffer_replace2(rtr->buf, cur_ptr, cur_end, trash.str, trash.len); /* FIXME: if the user adds a newline in the replacement, the * index will not be recalculated for now, and the new line * will not be counted as a new header. */ http_msg_move_end(&txn->rsp, delta); cur_end += delta; cur_end = (char *)http_parse_stsline(&txn->rsp, HTTP_MSG_RPVER, cur_ptr, cur_end + 1, NULL, NULL); if (unlikely(!cur_end)) return -1; /* we have a full respnse and we know that we have either a CR * or an LF at <ptr>. */ txn->status = strl2ui(rtr->buf->p + txn->rsp.sl.st.c, txn->rsp.sl.st.c_l); hdr_idx_set_start(&txn->hdr_idx, txn->rsp.sl.st.l, *cur_end == '\r'); /* there is no point trying this regex on headers */ return 1; } } return done; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,790
int apply_filters_to_request(struct session *s, struct channel *req, struct proxy *px) { struct http_txn *txn = &s->txn; struct hdr_exp *exp; for (exp = px->req_exp; exp; exp = exp->next) { int ret; /* * The interleaving of transformations and verdicts * makes it difficult to decide to continue or stop * the evaluation. */ if (txn->flags & (TX_CLDENY|TX_CLTARPIT)) break; if ((txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT || exp->action == ACT_PASS)) continue; /* if this filter had a condition, evaluate it now and skip to * next filter if the condition does not match. */ if (exp->cond) { ret = acl_exec_cond(exp->cond, px, s, txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)exp->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } /* Apply the filter to the request line. */ ret = apply_filter_to_req_line(s, req, exp); if (unlikely(ret < 0)) return -1; if (likely(ret == 0)) { /* The filter did not match the request, it can be * iterated through all headers. */ apply_filter_to_req_headers(s, req, exp); } } return 0; }
DoS Overflow
0
int apply_filters_to_request(struct session *s, struct channel *req, struct proxy *px) { struct http_txn *txn = &s->txn; struct hdr_exp *exp; for (exp = px->req_exp; exp; exp = exp->next) { int ret; /* * The interleaving of transformations and verdicts * makes it difficult to decide to continue or stop * the evaluation. */ if (txn->flags & (TX_CLDENY|TX_CLTARPIT)) break; if ((txn->flags & TX_CLALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_TARPIT || exp->action == ACT_PASS)) continue; /* if this filter had a condition, evaluate it now and skip to * next filter if the condition does not match. */ if (exp->cond) { ret = acl_exec_cond(exp->cond, px, s, txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)exp->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } /* Apply the filter to the request line. */ ret = apply_filter_to_req_line(s, req, exp); if (unlikely(ret < 0)) return -1; if (likely(ret == 0)) { /* The filter did not match the request, it can be * iterated through all headers. */ apply_filter_to_req_headers(s, req, exp); } } return 0; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,791
int apply_filters_to_response(struct session *s, struct channel *rtr, struct proxy *px) { struct http_txn *txn = &s->txn; struct hdr_exp *exp; for (exp = px->rsp_exp; exp; exp = exp->next) { int ret; /* * The interleaving of transformations and verdicts * makes it difficult to decide to continue or stop * the evaluation. */ if (txn->flags & TX_SVDENY) break; if ((txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_PASS)) { exp = exp->next; continue; } /* if this filter had a condition, evaluate it now and skip to * next filter if the condition does not match. */ if (exp->cond) { ret = acl_exec_cond(exp->cond, px, s, txn, SMP_OPT_DIR_RES|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)exp->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } /* Apply the filter to the status line. */ ret = apply_filter_to_sts_line(s, rtr, exp); if (unlikely(ret < 0)) return -1; if (likely(ret == 0)) { /* The filter did not match the response, it can be * iterated through all headers. */ if (unlikely(apply_filter_to_resp_headers(s, rtr, exp) < 0)) return -1; } } return 0; }
DoS Overflow
0
int apply_filters_to_response(struct session *s, struct channel *rtr, struct proxy *px) { struct http_txn *txn = &s->txn; struct hdr_exp *exp; for (exp = px->rsp_exp; exp; exp = exp->next) { int ret; /* * The interleaving of transformations and verdicts * makes it difficult to decide to continue or stop * the evaluation. */ if (txn->flags & TX_SVDENY) break; if ((txn->flags & TX_SVALLOW) && (exp->action == ACT_ALLOW || exp->action == ACT_DENY || exp->action == ACT_PASS)) { exp = exp->next; continue; } /* if this filter had a condition, evaluate it now and skip to * next filter if the condition does not match. */ if (exp->cond) { ret = acl_exec_cond(exp->cond, px, s, txn, SMP_OPT_DIR_RES|SMP_OPT_FINAL); ret = acl_pass(ret); if (((struct acl_cond *)exp->cond)->pol == ACL_COND_UNLESS) ret = !ret; if (!ret) continue; } /* Apply the filter to the status line. */ ret = apply_filter_to_sts_line(s, rtr, exp); if (unlikely(ret < 0)) return -1; if (likely(ret == 0)) { /* The filter did not match the response, it can be * iterated through all headers. */ if (unlikely(apply_filter_to_resp_headers(s, rtr, exp) < 0)) return -1; } } return 0; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,792
void check_response_for_cacheability(struct session *s, struct channel *rtr) { struct http_txn *txn = &s->txn; char *p1, *p2; char *cur_ptr, *cur_end, *cur_next; int cur_idx; if (!(txn->flags & TX_CACHEABLE)) return; /* Iterate through the headers. * we start with the start line. */ cur_idx = 0; cur_next = rtr->buf->p + hdr_idx_first_pos(&txn->hdr_idx); while ((cur_idx = txn->hdr_idx.v[cur_idx].next)) { struct hdr_idx_elem *cur_hdr; int val; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* We have one full header between cur_ptr and cur_end, and the * next header starts at cur_next. We're only interested in * "Cookie:" headers. */ val = http_header_match2(cur_ptr, cur_end, "Pragma", 6); if (val) { if ((cur_end - (cur_ptr + val) >= 8) && strncasecmp(cur_ptr + val, "no-cache", 8) == 0) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } } val = http_header_match2(cur_ptr, cur_end, "Cache-control", 13); if (!val) continue; /* OK, right now we know we have a cache-control header at cur_ptr */ p1 = cur_ptr + val; /* first non-space char after 'cache-control:' */ if (p1 >= cur_end) /* no more info */ continue; /* p1 is at the beginning of the value */ p2 = p1; while (p2 < cur_end && *p2 != '=' && *p2 != ',' && !isspace((unsigned char)*p2)) p2++; /* we have a complete value between p1 and p2 */ if (p2 < cur_end && *p2 == '=') { /* we have something of the form no-cache="set-cookie" */ if ((cur_end - p1 >= 21) && strncasecmp(p1, "no-cache=\"set-cookie", 20) == 0 && (p1[20] == '"' || p1[20] == ',')) txn->flags &= ~TX_CACHE_COOK; continue; } /* OK, so we know that either p2 points to the end of string or to a comma */ if (((p2 - p1 == 7) && strncasecmp(p1, "private", 7) == 0) || ((p2 - p1 == 8) && strncasecmp(p1, "no-cache", 8) == 0) || ((p2 - p1 == 8) && strncasecmp(p1, "no-store", 8) == 0) || ((p2 - p1 == 9) && strncasecmp(p1, "max-age=0", 9) == 0) || ((p2 - p1 == 10) && strncasecmp(p1, "s-maxage=0", 10) == 0)) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } if ((p2 - p1 == 6) && strncasecmp(p1, "public", 6) == 0) { txn->flags |= TX_CACHEABLE | TX_CACHE_COOK; continue; } } }
DoS Overflow
0
void check_response_for_cacheability(struct session *s, struct channel *rtr) { struct http_txn *txn = &s->txn; char *p1, *p2; char *cur_ptr, *cur_end, *cur_next; int cur_idx; if (!(txn->flags & TX_CACHEABLE)) return; /* Iterate through the headers. * we start with the start line. */ cur_idx = 0; cur_next = rtr->buf->p + hdr_idx_first_pos(&txn->hdr_idx); while ((cur_idx = txn->hdr_idx.v[cur_idx].next)) { struct hdr_idx_elem *cur_hdr; int val; cur_hdr = &txn->hdr_idx.v[cur_idx]; cur_ptr = cur_next; cur_end = cur_ptr + cur_hdr->len; cur_next = cur_end + cur_hdr->cr + 1; /* We have one full header between cur_ptr and cur_end, and the * next header starts at cur_next. We're only interested in * "Cookie:" headers. */ val = http_header_match2(cur_ptr, cur_end, "Pragma", 6); if (val) { if ((cur_end - (cur_ptr + val) >= 8) && strncasecmp(cur_ptr + val, "no-cache", 8) == 0) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } } val = http_header_match2(cur_ptr, cur_end, "Cache-control", 13); if (!val) continue; /* OK, right now we know we have a cache-control header at cur_ptr */ p1 = cur_ptr + val; /* first non-space char after 'cache-control:' */ if (p1 >= cur_end) /* no more info */ continue; /* p1 is at the beginning of the value */ p2 = p1; while (p2 < cur_end && *p2 != '=' && *p2 != ',' && !isspace((unsigned char)*p2)) p2++; /* we have a complete value between p1 and p2 */ if (p2 < cur_end && *p2 == '=') { /* we have something of the form no-cache="set-cookie" */ if ((cur_end - p1 >= 21) && strncasecmp(p1, "no-cache=\"set-cookie", 20) == 0 && (p1[20] == '"' || p1[20] == ',')) txn->flags &= ~TX_CACHE_COOK; continue; } /* OK, so we know that either p2 points to the end of string or to a comma */ if (((p2 - p1 == 7) && strncasecmp(p1, "private", 7) == 0) || ((p2 - p1 == 8) && strncasecmp(p1, "no-cache", 8) == 0) || ((p2 - p1 == 8) && strncasecmp(p1, "no-store", 8) == 0) || ((p2 - p1 == 9) && strncasecmp(p1, "max-age=0", 9) == 0) || ((p2 - p1 == 10) && strncasecmp(p1, "s-maxage=0", 10) == 0)) { txn->flags &= ~TX_CACHEABLE & ~TX_CACHE_COOK; return; } if ((p2 - p1 == 6) && strncasecmp(p1, "public", 6) == 0) { txn->flags |= TX_CACHEABLE | TX_CACHE_COOK; continue; } } }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,793
int del_hdr_value(struct buffer *buf, char **from, char *next) { char *prev = *from; if (*prev == ':') { /* We're removing the first value, preserve the colon and add a * space if possible. */ if (!http_is_crlf[(unsigned char)*next]) next++; prev++; if (prev < next) *prev++ = ' '; while (http_is_spht[(unsigned char)*next]) next++; } else { /* Remove useless spaces before the old delimiter. */ while (http_is_spht[(unsigned char)*(prev-1)]) prev--; *from = prev; /* copy the delimiter and if possible a space if we're * not at the end of the line. */ if (!http_is_crlf[(unsigned char)*next]) { *prev++ = *next++; if (prev + 1 < next) *prev++ = ' '; while (http_is_spht[(unsigned char)*next]) next++; } } return buffer_replace2(buf, prev, next, NULL, 0); }
DoS Overflow
0
int del_hdr_value(struct buffer *buf, char **from, char *next) { char *prev = *from; if (*prev == ':') { /* We're removing the first value, preserve the colon and add a * space if possible. */ if (!http_is_crlf[(unsigned char)*next]) next++; prev++; if (prev < next) *prev++ = ' '; while (http_is_spht[(unsigned char)*next]) next++; } else { /* Remove useless spaces before the old delimiter. */ while (http_is_spht[(unsigned char)*(prev-1)]) prev--; *from = prev; /* copy the delimiter and if possible a space if we're * not at the end of the line. */ if (!http_is_crlf[(unsigned char)*next]) { *prev++ = *next++; if (prev + 1 < next) *prev++ = ' '; while (http_is_spht[(unsigned char)*next]) next++; } } return buffer_replace2(buf, prev, next, NULL, 0); }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,794
extract_cookie_value(char *hdr, const char *hdr_end, char *cookie_name, size_t cookie_name_l, int list, char **value, int *value_l) { char *equal, *att_end, *att_beg, *val_beg, *val_end; char *next; /* we search at least a cookie name followed by an equal, and more * generally something like this : * Cookie: NAME1 = VALUE 1 ; NAME2 = VALUE2 ; NAME3 = VALUE3\r\n */ for (att_beg = hdr; att_beg + cookie_name_l + 1 < hdr_end; att_beg = next + 1) { /* Iterate through all cookies on this line */ while (att_beg < hdr_end && http_is_spht[(unsigned char)*att_beg]) att_beg++; /* find att_end : this is the first character after the last non * space before the equal. It may be equal to hdr_end. */ equal = att_end = att_beg; while (equal < hdr_end) { if (*equal == '=' || *equal == ';' || (list && *equal == ',')) break; if (http_is_spht[(unsigned char)*equal++]) continue; att_end = equal; } /* here, <equal> points to '=', a delimitor or the end. <att_end> * is between <att_beg> and <equal>, both may be identical. */ /* look for end of cookie if there is an equal sign */ if (equal < hdr_end && *equal == '=') { /* look for the beginning of the value */ val_beg = equal + 1; while (val_beg < hdr_end && http_is_spht[(unsigned char)*val_beg]) val_beg++; /* find the end of the value, respecting quotes */ next = find_cookie_value_end(val_beg, hdr_end); /* make val_end point to the first white space or delimitor after the value */ val_end = next; while (val_end > val_beg && http_is_spht[(unsigned char)*(val_end - 1)]) val_end--; } else { val_beg = val_end = next = equal; } /* We have nothing to do with attributes beginning with '$'. However, * they will automatically be removed if a header before them is removed, * since they're supposed to be linked together. */ if (*att_beg == '$') continue; /* Ignore cookies with no equal sign */ if (equal == next) continue; /* Now we have the cookie name between att_beg and att_end, and * its value between val_beg and val_end. */ if (att_end - att_beg == cookie_name_l && memcmp(att_beg, cookie_name, cookie_name_l) == 0) { /* let's return this value and indicate where to go on from */ *value = val_beg; *value_l = val_end - val_beg; return next + 1; } /* Set-Cookie headers only have the name in the first attr=value part */ if (!list) break; } return NULL; }
DoS Overflow
0
extract_cookie_value(char *hdr, const char *hdr_end, char *cookie_name, size_t cookie_name_l, int list, char **value, int *value_l) { char *equal, *att_end, *att_beg, *val_beg, *val_end; char *next; /* we search at least a cookie name followed by an equal, and more * generally something like this : * Cookie: NAME1 = VALUE 1 ; NAME2 = VALUE2 ; NAME3 = VALUE3\r\n */ for (att_beg = hdr; att_beg + cookie_name_l + 1 < hdr_end; att_beg = next + 1) { /* Iterate through all cookies on this line */ while (att_beg < hdr_end && http_is_spht[(unsigned char)*att_beg]) att_beg++; /* find att_end : this is the first character after the last non * space before the equal. It may be equal to hdr_end. */ equal = att_end = att_beg; while (equal < hdr_end) { if (*equal == '=' || *equal == ';' || (list && *equal == ',')) break; if (http_is_spht[(unsigned char)*equal++]) continue; att_end = equal; } /* here, <equal> points to '=', a delimitor or the end. <att_end> * is between <att_beg> and <equal>, both may be identical. */ /* look for end of cookie if there is an equal sign */ if (equal < hdr_end && *equal == '=') { /* look for the beginning of the value */ val_beg = equal + 1; while (val_beg < hdr_end && http_is_spht[(unsigned char)*val_beg]) val_beg++; /* find the end of the value, respecting quotes */ next = find_cookie_value_end(val_beg, hdr_end); /* make val_end point to the first white space or delimitor after the value */ val_end = next; while (val_end > val_beg && http_is_spht[(unsigned char)*(val_end - 1)]) val_end--; } else { val_beg = val_end = next = equal; } /* We have nothing to do with attributes beginning with '$'. However, * they will automatically be removed if a header before them is removed, * since they're supposed to be linked together. */ if (*att_beg == '$') continue; /* Ignore cookies with no equal sign */ if (equal == next) continue; /* Now we have the cookie name between att_beg and att_end, and * its value between val_beg and val_end. */ if (att_end - att_beg == cookie_name_l && memcmp(att_beg, cookie_name, cookie_name_l) == 0) { /* let's return this value and indicate where to go on from */ *value = val_beg; *value_l = val_end - val_beg; return next + 1; } /* Set-Cookie headers only have the name in the first attr=value part */ if (!list) break; } return NULL; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,795
char *find_hdr_value_end(char *s, const char *e) { int quoted, qdpair; quoted = qdpair = 0; for (; s < e; s++) { if (qdpair) qdpair = 0; else if (quoted) { if (*s == '\\') qdpair = 1; else if (*s == '"') quoted = 0; } else if (*s == '"') quoted = 1; else if (*s == ',') return s; } return s; }
DoS Overflow
0
char *find_hdr_value_end(char *s, const char *e) { int quoted, qdpair; quoted = qdpair = 0; for (; s < e; s++) { if (qdpair) qdpair = 0; else if (quoted) { if (*s == '\\') qdpair = 1; else if (*s == '"') quoted = 0; } else if (*s == '"') quoted = 1; else if (*s == ',') return s; } return s; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,796
enum http_meth_t find_http_meth(const char *str, const int len) { unsigned char m; const struct http_method_desc *h; m = ((unsigned)*str - 'A'); if (m < 26) { for (h = http_methods[m]; h->len > 0; h++) { if (unlikely(h->len != len)) continue; if (likely(memcmp(str, h->text, h->len) == 0)) return h->meth; }; return HTTP_METH_OTHER; } return HTTP_METH_NONE; }
DoS Overflow
0
enum http_meth_t find_http_meth(const char *str, const int len) { unsigned char m; const struct http_method_desc *h; m = ((unsigned)*str - 'A'); if (m < 26) { for (h = http_methods[m]; h->len > 0; h++) { if (unlikely(h->len != len)) continue; if (likely(memcmp(str, h->text, h->len) == 0)) return h->meth; }; return HTTP_METH_OTHER; } return HTTP_METH_NONE; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,797
find_url_param_pos(char* query_string, size_t query_string_l, char* url_param_name, size_t url_param_name_l, char delim) { char *pos, *last; pos = query_string; last = query_string + query_string_l - url_param_name_l - 1; while (pos <= last) { if (pos[url_param_name_l] == '=') { if (memcmp(pos, url_param_name, url_param_name_l) == 0) return pos; pos += url_param_name_l + 1; } while (pos <= last && !is_param_delimiter(*pos, delim)) pos++; pos++; } return NULL; }
DoS Overflow
0
find_url_param_pos(char* query_string, size_t query_string_l, char* url_param_name, size_t url_param_name_l, char delim) { char *pos, *last; pos = query_string; last = query_string + query_string_l - url_param_name_l - 1; while (pos <= last) { if (pos[url_param_name_l] == '=') { if (memcmp(pos, url_param_name, url_param_name_l) == 0) return pos; pos += url_param_name_l + 1; } while (pos <= last && !is_param_delimiter(*pos, delim)) pos++; pos++; } return NULL; }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,798
void free_http_req_rules(struct list *r) { struct http_req_rule *tr, *pr; list_for_each_entry_safe(pr, tr, r, list) { LIST_DEL(&pr->list); if (pr->action == HTTP_REQ_ACT_AUTH) free(pr->arg.auth.realm); regex_free(&pr->arg.hdr_add.re); free(pr); } }
DoS Overflow
0
void free_http_req_rules(struct list *r) { struct http_req_rule *tr, *pr; list_for_each_entry_safe(pr, tr, r, list) { LIST_DEL(&pr->list); if (pr->action == HTTP_REQ_ACT_AUTH) free(pr->arg.auth.realm); regex_free(&pr->arg.hdr_add.re); free(pr); } }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null
7,799
void free_http_res_rules(struct list *r) { struct http_res_rule *tr, *pr; list_for_each_entry_safe(pr, tr, r, list) { LIST_DEL(&pr->list); regex_free(&pr->arg.hdr_add.re); free(pr); } }
DoS Overflow
0
void free_http_res_rules(struct list *r) { struct http_res_rule *tr, *pr; list_for_each_entry_safe(pr, tr, r, list) { LIST_DEL(&pr->list); regex_free(&pr->arg.hdr_add.re); free(pr); } }
@@ -4886,8 +4886,8 @@ void http_end_txn_clean_session(struct session *s) s->req->cons->conn_retries = 0; /* used for logging too */ s->req->cons->exp = TICK_ETERNITY; s->req->cons->flags &= SI_FL_DONT_WAKE; /* we're in the context of process_session */ - s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT); - s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT); + s->req->flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA); + s->rep->flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA); s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST); s->flags &= ~(SN_CURR_SESS|SN_REDIRECTABLE|SN_SRV_REUSED); @@ -5430,7 +5430,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit * such as last chunk of data or trailers. */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next; msg->next = 0; @@ -5482,7 +5482,7 @@ int http_request_forward_body(struct session *s, struct channel *req, int an_bit missing_data: /* we may have some pending data starting at req->buf->p */ b_adv(req->buf, msg->next); - if (unlikely(!(s->rep->flags & CF_READ_ATTACHED))) + if (unlikely(!(s->req->flags & CF_WROTE_DATA))) msg->sov -= msg->next + MIN(msg->chunk_len, req->buf->i); msg->next = 0;
CWE-189
null
null