[BACK]Return to key.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / gzsig

Diff for /src/usr.bin/gzsig/Attic/key.c between version 1.5 and 1.6

version 1.5, 2006/04/03 01:33:09 version 1.6, 2010/08/11 18:38:30
Line 72 
Line 72 
 {  {
         struct stat st;          struct stat st;
         int fd;          int fd;
           int rval = -1;
   
         if ((fd = open(filename, O_RDONLY)) < 0)          if ((fd = open(filename, O_RDONLY)) < 0)
                 return (-1);                  goto done;
   
         if (fstat(fd, &st) < 0)          if (fstat(fd, &st) < 0)
                 return (-1);                  goto done;
   
         if (st.st_size == 0 || st.st_size >= SIZE_MAX) {          if (st.st_size == 0 || st.st_size >= SIZE_MAX) {
                 errno = EINVAL;                  errno = EINVAL;
                 return (-1);                  goto done;
         }          }
         if ((iov->iov_base = malloc(st.st_size + 1)) == NULL)          if ((iov->iov_base = malloc(st.st_size + 1)) == NULL)
                 return (-1);                  goto done;
   
         iov->iov_len = st.st_size;          iov->iov_len = st.st_size;
         ((u_char *)iov->iov_base)[iov->iov_len] = '\0';          ((u_char *)iov->iov_base)[iov->iov_len] = '\0';
   
         if (read(fd, iov->iov_base, iov->iov_len) != iov->iov_len) {          if (read(fd, iov->iov_base, iov->iov_len) != iov->iov_len) {
                 free(iov->iov_base);                  free(iov->iov_base);
                 return (-1);                  goto done;
         }          }
         close(fd);  
           rval = 0;
         return (0);  
   done:
           if (fd != -1)
               close(fd);
           return (rval);
 }  }
   
 struct key *  struct key *

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6