ReadFile() and GetStdHandle() are not very POSIX.
authorderaadt <deraadt@openbsd.org>
Sat, 19 Apr 2014 16:31:51 +0000 (16:31 +0000)
committerderaadt <deraadt@openbsd.org>
Sat, 19 Apr 2014 16:31:51 +0000 (16:31 +0000)
ok beck jsing

lib/libssl/src/apps/apps.c
lib/libssl/src/apps/apps.h
lib/libssl/src/apps/s_client.c
lib/libssl/src/apps/s_server.c

index 6413d5c..3a6c3b9 100644 (file)
@@ -2513,40 +2513,3 @@ app_isdir(const char *name)
         return -1;
 #endif
 }
-
-/* raw_read|write section */
-#if defined(_WIN32) && defined(STD_INPUT_HANDLE)
-int
-raw_read_stdin(void *buf, int siz)
-{
-       DWORD n;
-       if (ReadFile(GetStdHandle(STD_INPUT_HANDLE), buf, siz, &n, NULL))
-               return (n);
-       else
-               return (-1);
-}
-#else
-int
-raw_read_stdin(void *buf, int siz)
-{
-       return read(fileno(stdin), buf, siz);
-}
-#endif
-
-#if defined(_WIN32) && defined(STD_OUTPUT_HANDLE)
-int
-raw_write_stdout(const void *buf, int siz)
-{
-       DWORD n;
-       if (WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf, siz, &n, NULL))
-               return (n);
-       else
-               return (-1);
-}
-#else
-int
-raw_write_stdout(const void *buf, int siz)
-{
-       return write(fileno(stdout), buf, siz);
-}
-#endif
index 5501502..eae0f47 100644 (file)
@@ -320,8 +320,6 @@ unsigned char *next_protos_parse(unsigned short *outlen, const char *in);
 #define SERIAL_RAND_BITS       64
 
 int app_isdir(const char *);
-int raw_read_stdin(void *, int);
-int raw_write_stdout(const void *, int);
 
 #define TM_START       0
 #define TM_STOP                1
index 8c71d6b..fada082 100644 (file)
@@ -1524,7 +1524,7 @@ re_start:
                                goto shut;
                        }
                } else if (!ssl_pending && FD_ISSET(fileno(stdout), &writefds)) {
-                       i = raw_write_stdout(&(sbuf[sbuf_off]), sbuf_len);
+                       i = write(fileno(stdout), &(sbuf[sbuf_off]), sbuf_len);
 
                        if (i <= 0) {
                                BIO_printf(bio_c_out, "DONE\n");
@@ -1601,7 +1601,7 @@ re_start:
                        if (crlf) {
                                int j, lf_num;
 
-                               i = raw_read_stdin(cbuf, BUFSIZZ / 2);
+                               i = read(fileno(stdin), cbuf, BUFSIZZ / 2);
                                lf_num = 0;
                                /* both loops are skipped when i <= 0 */
                                for (j = 0; j < i; j++)
@@ -1617,7 +1617,7 @@ re_start:
                                }
                                assert(lf_num == 0);
                        } else
-                               i = raw_read_stdin(cbuf, BUFSIZZ);
+                               i = read(fileno(stdin), cbuf, BUFSIZZ);
 
                        if ((!c_ign_eof) && ((i <= 0) || (cbuf[0] == 'Q'))) {
                                BIO_printf(bio_err, "DONE\n");
index 3dd22e6..1082ee5 100644 (file)
@@ -1805,7 +1805,7 @@ sv_body(char *hostname, int s, unsigned char *context)
                        if (s_crlf) {
                                int j, lf_num;
 
-                               i = raw_read_stdin(buf, bufsize / 2);
+                               i = read(fileno(stdin), buf, bufsize / 2);
                                lf_num = 0;
                                /* both loops are skipped when i <= 0 */
                                for (j = 0; j < i; j++)
@@ -1821,7 +1821,7 @@ sv_body(char *hostname, int s, unsigned char *context)
                                }
                                assert(lf_num == 0);
                        } else
-                               i = raw_read_stdin(buf, bufsize);
+                               i = read(fileno(stdin), buf, bufsize);
                        if (!s_quiet) {
                                if ((i <= 0) || (buf[0] == 'Q')) {
                                        BIO_printf(bio_s_out, "DONE\n");
@@ -1954,7 +1954,7 @@ sv_body(char *hostname, int s, unsigned char *context)
 #endif
                                switch (SSL_get_error(con, i)) {
                                case SSL_ERROR_NONE:
-                                       raw_write_stdout(buf,
+                                       write(fileno(stdout), buf,
                                            (unsigned int) i);
                                        if (SSL_pending(con))
                                                goto again;