diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-10 14:46:09 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2023-04-10 14:47:38 +0200 |
commit | 611729eff386234b09d40780cdcc21fe72f6f8b8 (patch) | |
tree | a1adc317873335bce1b01f9b8bd9cb9abad82fcc | |
parent | 9bc2b6e88474a8ebb50c94f29320d343bd374928 (diff) | |
download | busybox-w32-611729eff386234b09d40780cdcc21fe72f6f8b8.tar.gz busybox-w32-611729eff386234b09d40780cdcc21fe72f6f8b8.tar.bz2 busybox-w32-611729eff386234b09d40780cdcc21fe72f6f8b8.zip |
mkfs_vfat: do not generate same volume_id when run in rapid succession
function old new delta
mkfs_vfat_main 1502 1523 +21
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/mkfs_vfat.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index 821371953..d2db78e1d 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c | |||
@@ -267,8 +267,9 @@ int mkfs_vfat_main(int argc UNUSED_PARAM, char **argv) | |||
267 | 267 | ||
268 | // cache device name | 268 | // cache device name |
269 | device_name = argv[0]; | 269 | device_name = argv[0]; |
270 | // default volume ID = creation time | 270 | // default volume ID: somewhat random (not crypto-strong) |
271 | volume_id = time(NULL); | 271 | // (mix in pid to avoid same IDs when run in rapid succession) |
272 | volume_id = time(NULL) ^ getpid(); | ||
272 | // truncate to exactly 11 chars, pad with spaces | 273 | // truncate to exactly 11 chars, pad with spaces |
273 | sprintf(volume_label11, "%-11.11s", arg_volume_label); | 274 | sprintf(volume_label11, "%-11.11s", arg_volume_label); |
274 | 275 | ||