Rajaram-Regupathy / libtypec

“libtypec” is aimed to provide a generic interface abstracting all platform complexity for user space to develop tools for efficient USB-C port management. The library can also enable development of diagnostic and debug tools to debug system issues around USB-C/USB PD topology.
34 stars 4 forks source link

fopen not being checked for failed open #10

Closed ColinIanKing closed 1 year ago

ColinIanKing commented 1 year ago

function get_opr_mode() is opening a file and not checking for a NULL fp on file open failure:

        FILE *fp = fopen(path, "r");

        fgets(buf, 64, fp);

...

       fclose(fp);

This will end up with NULL pointer dereferencing (and SIGSEGV faults).

Same for function get_cable_plug_type(), get_cable_type() and get_cable_mode_support()

Rajaram-Regupathy commented 1 year ago

Fixed Thanks