chiark / gitweb /
Add a snprinf wrapper which checks that the buffer was big enough
[elogind.git] / src / fsck / fsck.c
index 20b794094835c0f5c3a988694ca1fb084fbd08cd..78ceeb6fab384e4bdbc3b234c866060a1383d041 100644 (file)
@@ -222,7 +222,7 @@ int main(int argc, char *argv[]) {
         const char *device, *type;
         bool root_directory;
         int progress_pipe[2] = { -1, -1 };
         const char *device, *type;
         bool root_directory;
         int progress_pipe[2] = { -1, -1 };
-        char dash_c[2+10+1];
+        char dash_c[sizeof("-C")-1 + DECIMAL_STR_MAX(int) + 1];
         struct stat st;
 
         if (argc > 2) {
         struct stat st;
 
         if (argc > 2) {
@@ -336,8 +336,7 @@ int main(int argc, char *argv[]) {
                 cmdline[i++] = "-f";
 
         if (progress_pipe[1] >= 0) {
                 cmdline[i++] = "-f";
 
         if (progress_pipe[1] >= 0) {
-                snprintf(dash_c, sizeof(dash_c), "-C%i", progress_pipe[1]);
-                char_array_0(dash_c);
+                xsprintf(dash_c, "-C%i", progress_pipe[1]);
                 cmdline[i++] = dash_c;
         }
 
                 cmdline[i++] = dash_c;
         }