Re: [PATCH] Fix off-by-one errors in read.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks ok,

Regards,

Hans


On 05/27/2009 07:49 PM, Bill Nottingham wrote:
Only read in 63 bytes, to make sure we preserve any trailing NULs for
end of string.

Signed-off-by: Bill Nottingham<notting@xxxxxxxxxx>
---
  isys/devices.c |    8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/isys/devices.c b/isys/devices.c
index 1efff62..98c8769 100644
--- a/isys/devices.c
+++ b/isys/devices.c
@@ -68,7 +68,7 @@ struct device **getDevices(enum deviceType type) {
              fd = open(path, O_RDONLY);
              if (fd == -1)
                  continue;
-            if (read(fd, buf, 64)<= 0) {
+            if (read(fd, buf, 63)<= 0) {
                  close(fd);
                  continue;
              }
@@ -97,7 +97,7 @@ struct device **getDevices(enum deviceType type) {

                  if (fd == -1)
                      continue;
-                if (read(fd, buf, 64)<= 0) {
+                if (read(fd, buf, 63)<= 0) {
                      close(fd);
                      continue;
                  }
@@ -155,7 +155,7 @@ storagedone:
              fd = open(path, O_RDONLY);
              if (fd == -1)
                  continue;
-            if (read(fd, buf, 64)<= 0) {
+            if (read(fd, buf, 63)<= 0) {
                  close(fd);
                  continue;
              }
@@ -179,7 +179,7 @@ storagedone:
              fd = open(path, O_RDONLY);
              if (fd != -1) {
                  memset(buf, '\0', 64);
-                if (read(fd, buf, 64)>  0) {
+                if (read(fd, buf, 63)>  0) {
                      int i;
                      for (i = (strlen(buf)-1); isspace(buf[i]); i--)
                          buf[i] = '\0';

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux