Skip to content

segfautl on "lldptool -t -i eth2 -V PFC -c enabled : #1

@sowminiv

Description

@sowminiv

Man page at https://linux.die.net/man/8/lldptool-pfc claims this should work.
But I get a segfault at
(gdb) bt
#0 0x000000000040a993 in get_arg_val_list (ibuf=0x7fffffffc2cd "07enabled",
ilen=14, ioff=0x7fffffffb12c, args=0x6163e0, argvals=0x6163c0)
at lldp_util.c:1239
#1 0x0000000000403c86 in print_arg_value (ibuf=0x7fffffffc2cd "07enabled")
at lldptool_cmds.c:406
#2 0x0000000000403d65 in print_tlvs (cmd=0x7fffffffb1e0,
ibuf=0x7fffffffc2cd "07enabled") at lldptool_cmds.c:436
#3 0x0000000000404225 in print_cmd_response (
ibuf=0x7fffffffc2b3 "C3010000001504eth10080c20b07enabled", status=0)
at lldptool_cmds.c:559
#4 0x000000000040432a in print_response (
buf=0x7fffffffc2b0 "R00C3010000001504eth10080c20b07enabled", status=0)
at lldptool_cmds.c:591
#5 0x0000000000401f6c in parse_print_message (
msg=0x7fffffffc2b0 "R00C3010000001504eth10080c20b07enabled", print=1)
at lldptool.c:280
#6 0x0000000000402142 in _clif_command (clif=0x616010,
cmd=0x7fffffffd3d2 "M00000001C3010000001504eth1000080c20b07enabled",
print=1) at lldptool.c:337
#7 0x0000000000402180 in clif_command (clif=0x616010,
cmd=0x7fffffffd3d2 "M00000001C3010000001504eth1000080c20b07enabled", raw=0)
at lldptool.c:346
#8 0x000000000040359d in cli_cmd_gettlv (clif=0x616010, argc=1,
argv=0x7fffffffe590, cmd=0x7fffffffd3b0, raw=0) at lldptool_cmds.c:177
#9 0x0000000000402a5a in request (clif=0x616010, argc=8, argv=0x7fffffffe558)
at lldptool.c:643
#10 0x0000000000402f5f in main (argc=8, argv=0x7fffffffe558) at lldptool.c:796

Sounds like this needs
--- a/lldp_util.c
+++ b/lldp_util.c
@@ -1207,7 +1207,7 @@ int get_arg_val_list(char *ibuf, int ilen, int *ioff,
}
hexstr2bin(ibuf+*ioff, &arglen, sizeof(arglen));
*ioff += 2 * (int)sizeof(arglen);

  •           if (ilen - *ioff >= arglen) {
    
  •           if (ilen - *ioff >= 0) {
                      args[i] = ibuf+*ioff;
                      *ioff += arglen;
                      *(arglens+i) = arglen;
    

@@ -1217,7 +1217,7 @@ int get_arg_val_list(char *ibuf, int ilen, int *ioff,
sizeof(argvalue_len));
argvalue_len = ntohs(argvalue_len);
ioff += 2sizeof(argvalue_len);

  •                           if (ilen - *ioff >= argvalue_len) {
    
  •                           if (ilen - *ioff >= 0) {
                                      argvals[i] = ibuf+*ioff;
                                      *ioff += argvalue_len;
                                      *(argvallens+i) = argvalue_len;
    

But given that the existing code has cuss-words like ibuf+*ioff
(spaces are free, you know?) one can never tell what the author was thinking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions