]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
cgclassify: Fix clang warnings
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 29 Jul 2025 16:41:15 +0000 (16:41 +0000)
committerKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 1 Aug 2025 09:02:21 +0000 (14:32 +0530)
commitac9b431f3d0f7542b5cf75f1dce7bca4b3c07ee6
treef888d2d8874fd7cee7205fc205c98d6f5b951110
parent042360b02ebc476b8627e3be8723a8f2069dfc6d
cgclassify: Fix clang warnings

Fix the following clang warnings by shrinking the scan size from 4096 to
4095 to allow room for the null terminating character.

cgclassify.c:334:47: warning: 'sscanf' may overflow; destination buffer
in argument 4 has size 4096, but the corresponding specifier may require
size 4097 [-Wfortify-source]
  334 |                         ret = sscanf(buffer, "%d::%4096s\n",
&idx, cgrp_name);
      |
^
cgclassify.c:336:63: warning: 'sscanf' may overflow; destination buffer
in argument 5 has size 4096, but the corresponding specifier may require
size 4097 [-Wfortify-source]
  336 |                         ret = sscanf(buffer,
"%d:%[^:]:%4096s\n", &idx, ctrl_name, cgrp_name);
      |
^
cgclassify.c:497:40: warning: 'sscanf' may overflow; destination buffer
in argument 3 has size 4096, but the corresponding specifier may require
size 4097 [-Wfortify-source]
  497 |                 ret = sscanf(buffer, "%*s %4096s\n", cgrp_path);
      |                                                      ^

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
src/tools/cgclassify.c