diff --git a/ChangeLog b/ChangeLog
index 70b231df..9b2a44e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-01-08  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	bug #27505: serbb_posix does not cope with inverted pins
+	* serbb_posix (serbb_highpulsepin): apply PIN_MASK when
+	checking pin numbers.
+	* serbb_win32 (serbb_highpulsepin): (Dito.)
+
 2010-01-08  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	bug #28516: Linux/Dragon: Error message on exit
diff --git a/serbb_posix.c b/serbb_posix.c
index 8ea58db5..25b2e2bd 100644
--- a/serbb_posix.c
+++ b/serbb_posix.c
@@ -174,7 +174,7 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
 
 static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
 {
-  if ( pin < 1 || pin > DB9PINS )
+  if ( (pin & PIN_MASK) < 1 || (pin & PIN_MASK) > DB9PINS )
     return -1;
 
   serbb_setpin(pgm, pin, 1);
diff --git a/serbb_win32.c b/serbb_win32.c
index 8c755210..bbf27b76 100644
--- a/serbb_win32.c
+++ b/serbb_win32.c
@@ -223,8 +223,8 @@ static int serbb_getpin(PROGRAMMER * pgm, int pin)
 
 static int serbb_highpulsepin(PROGRAMMER * pgm, int pin)
 {
-        if (pin < 1 || pin > 7)
-                return -1;
+        if ( (pin & PIN_MASK) < 1 || (pin & PIN_MASK) > DB9PINS )
+          return -1;
 
         serbb_setpin(pgm, pin, 1);
 	if (pgm->ispdelay > 1)