ソースを参照

u-a: Do not try to readlink() a non-symlink

Return early in case the path is not a symlink, there's no point in
calling readlink() if we know it's going to fail.
Guillem Jover 15 年 前
親
コミット
c922a8f681
共有1 個のファイルを変更した、6 個の追加 と 0 個の削除を含む
  1. 6 0
      utils/update-alternatives.c

+ 6 - 0
utils/update-alternatives.c

@@ -289,6 +289,12 @@ areadlink(const char *linkname)
 	/* Allocate required memory to store the value of the symlink */
 	if (lstat(linkname, &st))
 		return NULL;
+
+	if (!S_ISLNK(st.st_mode)) {
+		errno = EINVAL;
+		return NULL;
+	}
+
 	buf = xmalloc(st.st_size + 1);
 
 	/* Read it and terminate the string properly */