Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-9830

string truncation from snprintf in libcfs/util/parser.c::Parser_list_commands()

Details

    • Bug
    • Resolution: Duplicate
    • Minor
    • None
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      Modern gcc warns that:

      util/parser.c: In function Б─≤Parser_list_commandsБ─≥:
      util/parser.c:575:25: error: Б─≤%2dБ─≥ directive output may be truncated writing between 2 and 10 bytes into a region of size 4 [-Werror=format-truncation=]
          snprintf(fmt, 6, "%%-%2ds", char_max - len);
                               ^~~
      util/parser.c:575:21: note: directive argument in the range [1, 2147483647]
          snprintf(fmt, 6, "%%-%2ds", char_max - len);
                           ^~~~~~~~~
      util/parser.c:575:4: note: Б─≤snprintfБ─≥ output between 6 and 14 bytes into a destination of size 6
          snprintf(fmt, 6, "%%-%2ds", char_max - len);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      cc1: all warnings being treated as errors
      make[4]: *** [autoMakefile:669: libcfsutil_a-parser.o] Error 1
      make[4]: Leaving directory '/home/green/smt/git/lustre-release/libcfs/libcfs'
      

      there's some funky business going on with presumed column width so I guess we cannot just increase 6 to 14?

      Attachments

        Issue Links

          Activity

            [LU-9830] string truncation from snprintf in libcfs/util/parser.c::Parser_list_commands()
            pjones Peter Jones made changes -
            Fix Version/s Original: Lustre 2.16.0 [ 15190 ]
            Resolution New: Duplicate [ 3 ]
            Status Original: Reopened [ 4 ] New: Resolved [ 5 ]
            pjones Peter Jones added a comment -

            Fixed under LU-16392

            pjones Peter Jones added a comment - Fixed under LU-16392
            pjones Peter Jones made changes -
            Resolution Original: Fixed [ 1 ]
            Status Original: Resolved [ 5 ] New: Reopened [ 4 ]
            adilger Andreas Dilger made changes -
            Fix Version/s New: Lustre 2.16.0 [ 15190 ]
            Resolution New: Fixed [ 1 ]
            Status Original: Open [ 1 ] New: Resolved [ 5 ]

            Fixed in commit v2_15_53-135-gb4cc570ad11c

            adilger Andreas Dilger added a comment - Fixed in commit v2_15_53-135-gb4cc570ad11c
            adilger Andreas Dilger made changes -
            Link New: This issue is related to LU-16392 [ LU-16392 ]

            The command truncation was fixed by patch https://review.whamcloud.com/49484 "LU-16392 utils: use --list-commands for bash completion".

            adilger Andreas Dilger added a comment - The command truncation was fixed by patch https://review.whamcloud.com/49484 " LU-16392 utils: use --list-commands for bash completion ".

            Is this resolved ?

            simmonsja James A Simmons added a comment - Is this resolved ?

            The compiler problems were fixed with patch https://review.whamcloud.com/35384 "LU-6142 util: Fix style issues for parser.c", but there are still a couple of commands truncated by one character - "changelog_deregister" and "lustre_build_version". The latter could likely be removed - it was superseded in v2_6_50_0-16-g593b6ab6d219 with "lctl get_param version" and "--version", but "changelog_deregister" can't.

            It would probably make sense to add a check to prevent new commands > 19 characters in length from being added.

            adilger Andreas Dilger added a comment - The compiler problems were fixed with patch https://review.whamcloud.com/35384 " LU-6142 util: Fix style issues for parser.c ", but there are still a couple of commands truncated by one character - " changelog_deregister " and " lustre_build_version ". The latter could likely be removed - it was superseded in v2_6_50_0-16-g593b6ab6d219 with " lctl get_param version " and " --version ", but " changelog_deregister " can't. It would probably make sense to add a check to prevent new commands > 19 characters in length from being added.
            adilger Andreas Dilger made changes -
            Link New: This issue is related to LU-6142 [ LU-6142 ]

            People

              wc-triage WC Triage
              green Oleg Drokin
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: