提交 0327ff07 编写于 作者: E Eric Blake

uuid: fix off-by-one

Detected by Coverity.  Although unlikely, if we are ever started
with stdin closed, we could reach a situation where we open a
uuid file but then fail to close it, making that file the new
stdin for the rest of the process.

* src/util/uuid.c (getDMISystemUUID): Allow for stdin.
上级 d98a3d4a
/*
* Copyright (C) 2007-2011 Red Hat, Inc.
* Copyright (C) 2007-2012 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -236,7 +236,7 @@ getDMISystemUUID(char *uuid, int len)
while (paths[i]) {
int fd = open(paths[i], O_RDONLY);
if (fd > 0) {
if (fd >= 0) {
if (saferead(fd, uuid, len) == len) {
VIR_FORCE_CLOSE(fd);
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册