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

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

    XMLWordPrintable

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

            People

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

              Dates

                Created:
                Updated:
                Resolved: