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

sg_logs: Fix parameter lengths in show_data_compression_page #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

patrickdowling
Copy link

For the parameters in show_data_compression_page the length pl is initialized from bp[3] and checked for 0 || > 8, but the value passed to sg_get_unaligned_be is off-by-four. So all values in this page were effectively truncated to 0.

Output from sg_logs /dev/sg0 -p 0x1b before

Data compression log page  (ssc-4) [0x1b]
  Read compression ratio x100: 0
  Write compression ratio x100: 0
  Megabytes transferred to server: 0
  Bytes transferred to server: 0
  Megabytes read from tape: 0
  Bytes read from tape: 0
  Megabytes transferred from server: 0
  Bytes transferred from server: 0
  Megabytes written to tape: 0
  Bytes written to tape: 0
  Data compression enabled: 0
  unknown Parameter code = 0xabcd, contents in hex:
    00 00 00 00

and after fix

Data compression log page  (ssc-4) [0x1b]
  Read compression ratio x100: 42
  Write compression ratio x100: 84
  Megabytes transferred to server: 1234
  Bytes transferred to server: 4567
  Megabytes read from tape: 0
  Bytes read from tape: 0
  Megabytes transferred from server: 0
  Bytes transferred from server: 0
  Megabytes written to tape: 0
  Bytes written to tape: 0
  Data compression enabled: 1
  unknown Parameter code = 0xabcd, contents in hex:
    00 00 00 00 ff 00 ff 00

I'm still playing around with emulation code and not an actual device, yes, so those are dummy values.
The unknown parameter was injected for the 8 byte length, the values in the page covered 1/2/4 already. I think the data I'm generating is correct, but :)

(Similar-ish code in that file sometimes prefers pl + 4 but made for a more invasive change).

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.

None yet

1 participant