aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--common/ChangeLog8
-rw-r--r--common/iobuf.c20
-rw-r--r--common/ttyio.c16
-rw-r--r--common/util.h4
4 files changed, 30 insertions, 18 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index 66e935b28..caabdd4cf 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,11 @@
+2003-09-23 Werner Koch <[email protected]>
+
+ * iobuf.c (check_special_filename): Replaced is isdigit by digitp
+ to avoid passing negative values and potential locale problems.
+ Problem noted by Christian Biere.
+
+ * util.h (ascii_isspace): New.
+
2003-09-18 Werner Koch <[email protected]>
* ttyio.c (tty_fprintf): New.
diff --git a/common/iobuf.c b/common/iobuf.c
index 773e2993b..4d735397e 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -101,7 +101,7 @@ typedef struct close_cache_s *CLOSE_CACHE;
static CLOSE_CACHE close_cache;
#endif
-#ifdef __MINGW32__
+#ifdef _WIN32
typedef struct
{
int sock;
@@ -112,7 +112,7 @@ typedef struct
char fname[1]; /* name of the file */
}
sock_filter_ctx_t;
-#endif /*__MINGW32__*/
+#endif /*_WIN32*/
/* The first partial length header block must be of size 512
* to make it easier (and efficienter) we use a min. block size of 512
@@ -580,7 +580,7 @@ file_filter (void *opaque, int control, iobuf_t chain, byte * buf,
return rc;
}
-#ifdef __MINGW32__
+#ifdef _WIN32
/* Becuase sockets are an special object under Lose32 we have to
* use a special filter */
static int
@@ -667,7 +667,7 @@ sock_filter (void *opaque, int control, iobuf_t chain, byte * buf,
}
return rc;
}
-#endif /*__MINGW32__*/
+#endif /*_WIN32*/
/****************
* This is used to implement the block write mode.
@@ -1171,7 +1171,7 @@ check_special_filename (const char *fname)
int i;
fname += 2;
- for (i = 0; isdigit (fname[i]); i++)
+ for (i = 0; digitp (fname+i); i++)
;
if (!fname[i])
return atoi (fname);
@@ -1262,7 +1262,7 @@ iobuf_t
iobuf_sockopen (int fd, const char *mode)
{
iobuf_t a;
-#ifdef __MINGW32__
+#ifdef _WIN32
sock_filter_ctx_t *scx;
size_t len;
@@ -1405,7 +1405,7 @@ iobuf_ioctl (iobuf_t a, int cmd, int intval, void *ptrval)
b->keep_open = intval;
return 0;
}
-#ifdef __MINGW32__
+#ifdef _WIN32
else if (!a->chain && a->filter == sock_filter)
{
sock_filter_ctx_t *b = a->filter_ov;
@@ -1440,7 +1440,7 @@ iobuf_ioctl (iobuf_t a, int cmd, int intval, void *ptrval)
b->no_cache = intval;
return 0;
}
-#ifdef __MINGW32__
+#ifdef _WIN32
else if (!a->chain && a->filter == sock_filter)
{
sock_filter_ctx_t *b = a->filter_ov;
@@ -2363,7 +2363,7 @@ iobuf_read_line (iobuf_t a, byte ** addr_of_buffer,
int
iobuf_translate_file_handle (int fd, int for_write)
{
-#ifdef __MINGW32__
+#ifdef _WIN32
{
int x;
@@ -2387,7 +2387,7 @@ iobuf_translate_file_handle (int fd, int for_write)
static int
translate_file_handle (int fd, int for_write)
{
-#ifdef __MINGW32__
+#ifdef _WIN32
#ifdef FILE_FILTER_USES_STDIO
fd = iobuf_translate_file_handle (fd, for_write);
#else
diff --git a/common/ttyio.c b/common/ttyio.c
index c77b4a85a..eab805e20 100644
--- a/common/ttyio.c
+++ b/common/ttyio.c
@@ -37,7 +37,7 @@
#define HAVE_TCGETATTR
#endif
#endif
-#ifdef __MINGW32__ /* use the odd Win32 functions */
+#ifdef _WIN32 /* use the odd Win32 functions */
#include <windows.h>
#ifdef HAVE_TCGETATTR
#error mingw32 and termios
@@ -51,7 +51,7 @@
#define CONTROL_D ('D' - 'A' + 1)
-#ifdef __MINGW32__ /* use the odd Win32 functions */
+#ifdef _WIN32 /* use the odd Win32 functions */
static struct {
HANDLE in, out;
} con;
@@ -124,7 +124,7 @@ init_ttyfp(void)
if( initialized )
return;
-#if defined(__MINGW32__)
+#if defined(_WIN32)
{
SECURITY_ATTRIBUTES sa;
@@ -194,7 +194,7 @@ tty_printf( const char *fmt, ... )
init_ttyfp();
va_start( arg_ptr, fmt ) ;
-#ifdef __MINGW32__
+#ifdef _WIN32
{
char *buf = NULL;
int n;
@@ -241,7 +241,7 @@ tty_fprintf (FILE *fp, const char *fmt, ... )
init_ttyfp();
va_start( arg_ptr, fmt ) ;
-#ifdef __MINGW32__
+#ifdef _WIN32
{
char *buf = NULL;
int n;
@@ -278,7 +278,7 @@ tty_print_string ( const byte *p, size_t n )
if( !initialized )
init_ttyfp();
-#ifdef __MINGW32__
+#ifdef _WIN32
/* not so effective, change it if you want */
for( ; n; n--, p++ )
if( iscntrl( *p ) ) {
@@ -372,7 +372,7 @@ do_get( const char *prompt, int hidden )
buf = xmalloc((n=50));
i = 0;
-#ifdef __MINGW32__ /* windoze version */
+#ifdef _WIN32 /* windoze version */
if( hidden )
SetConsoleMode(con.in, HID_INPMODE );
@@ -527,7 +527,7 @@ tty_kill_prompt()
last_prompt_len = 0;
if( !last_prompt_len )
return;
-#ifdef __MINGW32__
+#ifdef _WIN32
tty_printf("\r%*s\r", last_prompt_len, "");
#else
{
diff --git a/common/util.h b/common/util.h
index 045851481..78aa2f890 100644
--- a/common/util.h
+++ b/common/util.h
@@ -107,6 +107,10 @@ int asprintf (char **result, const char *format, ...);
#define hexdigitp(a) (digitp (a) \
|| (*(a) >= 'A' && *(a) <= 'F') \
|| (*(a) >= 'a' && *(a) <= 'f'))
+ /* Note this isn't identical to a C locale isspace() without \f and
+ \v, but works for the purposes used here. */
+#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t')
+
/* the atoi macros assume that the buffer has only valid digits */
#define atoi_1(p) (*(p) - '0' )
#define atoi_2(p) ((atoi_1(p) * 10) + atoi_1((p)+1))