summaryrefslogtreecommitdiffstats
path: root/libuuid/src/test_uuid.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
commit8bb05ac73a5b448b339ce0bc8d396c82c459b47f (patch)
tree1fdda006866bca20d41cb206767ea5241e36852f /libuuid/src/test_uuid.c
parentAdding debian version 2.39.3-11. (diff)
downloadutil-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.tar.xz
util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libuuid/src/test_uuid.c')
-rw-r--r--libuuid/src/test_uuid.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/libuuid/src/test_uuid.c b/libuuid/src/test_uuid.c
index 9907911..06d1589 100644
--- a/libuuid/src/test_uuid.c
+++ b/libuuid/src/test_uuid.c
@@ -66,24 +66,30 @@ static int test_uuid(const char * uuid, int isValid)
static int check_uuids_in_file(const char *file)
{
- int fd, ret = 0;
- size_t sz;
- char str[UUID_STR_LEN];
+ int ret = 0;
+ size_t alloc = 0;
+ ssize_t sz;
+ char *str = NULL;
+ FILE *f;
uuid_t uuidBits;
- if ((fd = open(file, O_RDONLY)) < 0) {
+ if ((f = fopen(file, "r")) == NULL) {
warn("%s", file);
return 1;
}
- while ((sz = read(fd, str, sizeof(str))) != 0) {
- str[sizeof(str) - 1] = '\0';
+ while ((sz = getline(&str, &alloc, f)) != -1) {
+ if (sz == 0 || str[0] == '\n')
+ continue;
+ if (str[sz - 1] == '\n')
+ str[sz - 1] = '\0';
if (uuid_parse(str, uuidBits)) {
warnx("%s: %s", file, str);
ret++;
}
}
- close(fd);
+ fclose(f);
+ free(str);
return ret;
}