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

Can't parse a hid-dump - invalid item encountered #18

Open
Duckbuster opened this issue Sep 11, 2017 · 5 comments
Open

Can't parse a hid-dump - invalid item encountered #18

Duckbuster opened this issue Sep 11, 2017 · 5 comments

Comments

@Duckbuster
Copy link

I'm trying to convert a hid-dump with hidrd-convert. but it says invalid item encountered.
this is what I am trying to do:

cat nano_hid_dump | grep -v : | xxd -r -p | hidrd-convert -o spec > nano_spec
Failed to read input item at offset 728:
invalid item encountered

The hid_dump in question I have uploaded here:
https://a.lolisandstuff.moe/pbuwfny

@tmk
Copy link

tmk commented Sep 11, 2017

This online parser shows your dump includes three invalid bytes at end of file.
http://eleccelerator.com/usbdescreqparser/

With removing those bytes from the dump the command works well. This is not a bug but it would be useful if we can get halfway converted output even when error occurs.

EDIT: I'm not sure if this is safe but I could get output anyhoo.

diff --git a/src/hidrd-convert.c b/src/hidrd-convert.c
index 8945217..564336c 100644
--- a/src/hidrd-convert.c
+++ b/src/hidrd-convert.c
@@ -351,7 +351,7 @@ process(const char *input_name,
         fprintf(stderr, "Failed to read input item at %s:\n%s\n",
                 (posstr = hidrd_src_fmtpos(input, pos)),
                 (err = hidrd_src_errmsg(input)));
-        goto cleanup;
+        //goto cleanup;
     }
 
     /*

@spbnick
Copy link
Member

spbnick commented Sep 20, 2017

Thank you, @Duckbuster, @tmk, I agree it would be good to handle invalid bytes. I think the right way would be to preserve and output them as such, i.e. invalid bytes. I only need to find time to implement that.

@S4mw1s3
Copy link

S4mw1s3 commented Sep 28, 2017

Those invalid bytes can be preserved, but I think a warning should also be shown that there were invalid bytes because thanks to the error that is shown now, we found out that there was an issue in usbhid-dump.

I'm a colleague of @Duckbuster and I started investigating why we got these invalid bytes in the first place. We found that we needed this fix in usbhid-dump (DIGImend/usbhid-dump@cc74aae). If the error was not shown in hidrd-convert and the invalid bytes were silently preserved, I would have ended up with an invalid hid descriptor...

The fix is already old but it didn't end up in the usbhid-dump version in our distro because no release of usbutils was made since that fix. I asked for a new release of usbutils (gregkh/usbutils#57) and in the mean time I'll use a version of usbhid-dump which I compiled myself.

Thanks for the good work!

@spbnick
Copy link
Member

spbnick commented Sep 28, 2017

Thank you, that's good to hear. Let's leave this issue open, though, as there are more broken devices out there.

@S4mw1s3
Copy link

S4mw1s3 commented Sep 28, 2017

FYI, Just found out now but this one is more or less a duplicate of #11 .

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

No branches or pull requests

4 participants