Change License from GPLv2 only to GPLv2+ ("or any later").
[platform/upstream/cryptsetup.git] / lib / utils_wipe.c
index e6190e4..858964c 100644 (file)
@@ -3,10 +3,12 @@
  *
  * Copyright (C) 2004-2007, Clemens Fruhwirth <clemens@endorphin.org>
  * Copyright (C) 2011-2012, Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2009-2012, Milan Broz
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -136,7 +138,8 @@ int crypt_wipe(struct device *device,
                return -EINVAL;
        }
 
-       if (type == CRYPT_WIPE_DISK) {
+       if (type == CRYPT_WIPE_DISK && S_ISBLK(st.st_mode)) {
+               rotational = 0;
                if (!crypt_sysfs_get_rotational(major(st.st_rdev),
                                                minor(st.st_rdev),
                                                &rotational))
@@ -160,6 +163,7 @@ int crypt_wipe(struct device *device,
        if (exclusive && S_ISBLK(st.st_mode))
                flags |= O_EXCL;
 
+       /* coverity[toctou] */
        devfd = open(device_path(device), flags);
        if (devfd == -1) {
                free(buffer);