Merge branch 'upstream' into tizen
[platform/upstream/cryptsetup.git] / lib / utils_loop.c
index 681c123..b5394de 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * 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
@@ -237,8 +237,9 @@ static char *_sysfs_backing_file(const char *loop)
        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)