apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/file_io/win32 open.c
Date Wed, 13 Feb 2002 02:28:01 GMT
wrowe       02/02/12 18:28:01

  Modified:    file_io/win32 open.c
  Log:
    Protect us from both NULL and INVALID_FILE_HANDLE results.
  
  Revision  Changes    Path
  1.95      +24 -6     apr/file_io/win32/open.c
  
  Index: open.c
  ===================================================================
  RCS file: /home/cvs/apr/file_io/win32/open.c,v
  retrieving revision 1.94
  retrieving revision 1.95
  diff -u -r1.94 -r1.95
  --- open.c	12 Feb 2002 01:32:55 -0000	1.94
  +++ open.c	13 Feb 2002 02:28:00 -0000	1.95
  @@ -543,9 +543,15 @@
   #else
       apr_os_file_t file_handle;
   
  +    apr_set_os_error(APR_SUCCESS);
       file_handle = GetStdHandle(STD_ERROR_HANDLE);
  -    if (file_handle == INVALID_HANDLE_VALUE)
  -        return APR_EINVAL;
  +    if (!file_handle || (file_handle == INVALID_HANDLE_VALUE)) {
  +        apr_status_t rv = apr_get_os_error();
  +        if (rv == APR_SUCCESS) {
  +            return APR_EINVAL;
  +        }
  +        return rv;
  +    }
   
       return apr_os_file_put(thefile, &file_handle, 0, cont);
   #endif
  @@ -558,9 +564,15 @@
   #else
       apr_os_file_t file_handle;
   
  +    apr_set_os_error(APR_SUCCESS);
       file_handle = GetStdHandle(STD_OUTPUT_HANDLE);
  -    if (file_handle == INVALID_HANDLE_VALUE)
  -        return APR_EINVAL;
  +    if (!file_handle || (file_handle == INVALID_HANDLE_VALUE)) {
  +        apr_status_t rv = apr_get_os_error();
  +        if (rv == APR_SUCCESS) {
  +            return APR_EINVAL;
  +        }
  +        return rv;
  +    }
   
       return apr_os_file_put(thefile, &file_handle, 0, cont);
   #endif
  @@ -573,9 +585,15 @@
   #else
       apr_os_file_t file_handle;
   
  +    apr_set_os_error(APR_SUCCESS);
       file_handle = GetStdHandle(STD_INPUT_HANDLE);
  -    if (file_handle == INVALID_HANDLE_VALUE)
  -        return APR_EINVAL;
  +    if (!file_handle || (file_handle == INVALID_HANDLE_VALUE)) {
  +        apr_status_t rv = apr_get_os_error();
  +        if (rv == APR_SUCCESS) {
  +            return APR_EINVAL;
  +        }
  +        return rv;
  +    }
   
       return apr_os_file_put(thefile, &file_handle, 0, cont);
   #endif
  
  
  

Mime
View raw message