-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
oplock and lease break pdu handling #373
Conversation
… add flag to allow passing ownership of write buffer, use 0-copy read when possible
… deal with size/offsets
@@ -831,6 +830,7 @@ | |||
req.security_mode = (uint8_t)smb2->security_mode; | |||
|
|||
if (smb2->sec == SMB2_SEC_NTLMSSP) { | |||
/*ntlmssp_set_spnego_wrapping(c_data->auth_data, 1);*/ |
Check notice
Code scanning / CodeQL
Commented-out code Note
smb2_encode_file_fs_device_info(smb2, | ||
(struct smb2_file_fs_device_info *)rep->output_buffer, iov); | ||
rep->output_buffer_length = iov->len; | ||
break; | ||
case SMB2_FILE_FS_ATTRIBUTE_INFORMATION: | ||
case SMB2_FILE_NORMALIZED_NAME_INFORMATION: | ||
break; | ||
case SMB2_FILE_PIPE_INFORMATION: | ||
break; | ||
case SMB2_FILE_PIPE_LOCAL_INFORMATION: | ||
break; | ||
case SMB2_FILE_PIPE_REMOTE_INFORMATION: | ||
break; | ||
case SMB2_FILE_POSITION_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_position_info(smb2, | ||
(struct smb2_file_position_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_FILE_STANDARD_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_standard_info(smb2, | ||
(struct smb2_file_standard_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_FILE_STREAM_INFORMATION: | ||
break; | ||
case SMB2_FILE_INFO_CLASS_RESERVED: | ||
break; | ||
default: | ||
break; | ||
} | ||
break; | ||
case SMB2_0_INFO_FILESYSTEM: | ||
switch (req->file_info_class) { | ||
case SMB2_FILE_FS_ATTRIBUTE_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_attribute_info(smb2, | ||
(struct smb2_file_fs_attribute_info *)rep->output_buffer, iov); | ||
rep->output_buffer_length = iov->len; | ||
break; | ||
case SMB2_FILE_FS_CONTROL_INFORMATION: | ||
break; | ||
case SMB2_FILE_FS_FULL_SIZE_INFORMATION: | ||
break; | ||
case SMB2_FILE_FS_SECTOR_SIZE_INFORMATION: | ||
break; | ||
default: | ||
len = -1; | ||
break; | ||
} | ||
(struct smb2_file_fs_attribute_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_FILE_FS_CONTROL_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_control_info(smb2, | ||
(struct smb2_file_fs_control_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_FILE_FS_DEVICE_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_device_info(smb2, | ||
(struct smb2_file_fs_device_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_0_INFO_SECURITY: | ||
case SMB2_FILE_FS_FULL_SIZE_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_full_size_info(smb2, | ||
(struct smb2_file_fs_full_size_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_0_INFO_QUOTA: | ||
case SMB2_FILE_FS_OBJECT_ID_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_object_id_info(smb2, | ||
(struct smb2_file_fs_object_id_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_FILE_FS_SECTOR_SIZE_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_sector_size_info(smb2, | ||
(struct smb2_file_fs_sector_size_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_FILE_FS_SIZE_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_size_info(smb2, | ||
(struct smb2_file_fs_size_info *)rep->output_buffer, iov); | ||
break; | ||
case SMB2_FILE_FS_VOLUME_INFORMATION: | ||
created_output_buffer_length = | ||
smb2_encode_file_fs_volume_info(smb2, | ||
(struct smb2_file_fs_volume_info *)rep->output_buffer, iov); | ||
break; | ||
default: | ||
return 0; | ||
break; | ||
} | ||
break; | ||
case SMB2_0_INFO_SECURITY: | ||
break; | ||
case SMB2_0_INFO_QUOTA: | ||
break; | ||
default: | ||
return 0; | ||
} |
Check notice
Code scanning / CodeQL
Long switch case Note
1 (60 lines)
Switch has at least one case that is too long:
2 (45 lines)
return 0; | ||
} | ||
|
||
if (created_output_buffer_length < 0) { |
Check warning
Code scanning / CodeQL
Comparison result is always the same Warning
smb2_set_uint32(vec, 8, fs->volume_serial_number); | ||
smb2_set_uint8(vec, 16, fs->supports_objects); | ||
smb2_set_uint8(vec, 17, fs->reserved); | ||
name = smb2_utf8_to_utf16((char*)fs->volume_label); |
Check failure
Code scanning / CodeQL
Inconsistent nullness check Error
Merged, thanks! Sorry for the delay to review and merge. |
Adds basic oplock-break and lease-break handling. They are a bit special in that they use the same command code but have different stuct sizes, so the "fixed" part of the pdu is only the 2 byte struct size and the "variable" part is used to read in the rest of the pdu depending on sub-type.
Tested and working