/*
* loopback block device utilities
*
- * Copyright (C) 2009-2020 Red Hat, Inc. All rights reserved.
- * Copyright (C) 2009-2020 Milan Broz
+ * Copyright (C) 2009-2021 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2009-2021 Milan Broz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
if (stat(loop, &st) || !S_ISBLK(st.st_mode))
return NULL;
- snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/loop/backing_file",
- major(st.st_rdev), minor(st.st_rdev));
+ if (snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/loop/backing_file",
+ major(st.st_rdev), minor(st.st_rdev)) < 0)
+ return NULL;
fd = open(buf, O_RDONLY);
if (fd < 0)