Skip to content
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

Merged
merged 21 commits into from
Oct 23, 2024
Merged

Conversation

bdodge
Copy link
Contributor

@bdodge bdodge commented Oct 3, 2024

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

lib/pdu.c Fixed Show fixed Hide fixed
@bdodge bdodge changed the title oplock and lease break pdu handling (untested) oplock and lease break pdu handling Oct 5, 2024
@@ -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

This comment appears to contain commented-out code.
Comment on lines +170 to +284
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

Switch has at least one case that is too long:
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

Comparison is always false because created_output_buffer_length >= 0.
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

The result of this call to smb2_utf8_to_utf16 is not checked for null, but 88% of calls to smb2_utf8_to_utf16 check for null.
@sahlberg sahlberg merged commit 0d94ee0 into sahlberg:master Oct 23, 2024
14 of 16 checks passed
@sahlberg
Copy link
Owner

Merged, thanks! Sorry for the delay to review and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants