Index: buffer.c
===================================================================
RCS file: /cvs/src/sp12/src/buffer.c,v
retrieving revision 1.1
retrieving revision 1.4
diff -u -r1.1 -r1.4
--- buffer.c	6 Jan 2010 17:55:15 -0000	1.1
+++ buffer.c	6 Jan 2010 18:59:30 -0000	1.4
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <time.h>
 #include "sp12.h"
+#include "dos_cpt.h"
 
 
 /* Converts address or data string to number, automatically          */
@@ -394,26 +395,26 @@
          addressPerLine = 0x08;
          loByte = (unsigned char) buffer[address];
          hiByte = (unsigned char) (buffer[address] >> 8);
-         sprintf(lineBuf, "%02x %02x ", hiByte, loByte);
-         strcat(dataStr, lineBuf);
+         snprintf(lineBuf, sizeof(lineBuf), "%02x %02x ", hiByte, loByte);
+         strlcat(dataStr, lineBuf, sizeof(dataStr));
          if ((hiByte > 31) && (hiByte < 127))
-            sprintf(lineBuf, "%c", hiByte);
+            snprintf(lineBuf, sizeof(lineBuf), "%c", hiByte);
          else
-            sprintf(lineBuf, ".");
-         strcat(asciiStr, lineBuf);
+            snprintf(lineBuf, sizeof(lineBuf), ".");
+         strlcat(asciiStr, lineBuf, sizeof(asciiStr));
          if ((loByte > 31) && (loByte < 127))
-            sprintf(lineBuf, "%c", loByte);
+            snprintf(lineBuf, sizeof(lineBuf), "%c", loByte);
          else
-            sprintf(lineBuf, ".");
-         strcat(asciiStr, lineBuf);
+            snprintf(lineBuf, sizeof(lineBuf), ".");
+         strlcat(asciiStr, lineBuf, sizeof(asciiStr));
       } else {
-         sprintf(lineBuf, "%02x ", buffer[address]);
-         strcat(dataStr, lineBuf);
+         snprintf(lineBuf, sizeof(lineBuf), "%02x ", buffer[address]);
+         strlcat(dataStr, lineBuf, sizeof(dataStr));
          if ((buffer[address] > 31) && (buffer[address] < 127))
-            sprintf(lineBuf, "%c", buffer[address]);
+            snprintf(lineBuf, sizeof(lineBuf), "%c", buffer[address]);
          else
-            sprintf(lineBuf, ".");
-         strcat(asciiStr, lineBuf);
+            snprintf(lineBuf, sizeof(lineBuf), ".");
+         strlcat(asciiStr, lineBuf, sizeof(asciiStr));
       }
    }
    if ((fprintf(filePtr, "%06lx  %s  %s\n",
@@ -509,26 +510,26 @@
          addressPerLine = 0x08;
          loByte = (unsigned char) buffer[address];
          hiByte = (unsigned char) (buffer[address] >> 8);
-         sprintf(lineBuf, "%02x %02x ", hiByte, loByte);
-         strcat(dataStr, lineBuf);
+         snprintf(lineBuf, sizeof(lineBuf), "%02x %02x ", hiByte, loByte);
+         strlcat(dataStr, lineBuf, sizeof(dataStr));
          if ((hiByte > 31) && (hiByte < 127))
-            sprintf(lineBuf, "%c", hiByte);
+            snprintf(lineBuf, sizeof(lineBuf), "%c", hiByte);
          else
-            sprintf(lineBuf, ".");
-         strcat(asciiStr, lineBuf);
+            snprintf(lineBuf, sizeof(lineBuf), ".");
+         strlcat(asciiStr, lineBuf, sizeof(asciiStr));
          if ((loByte > 31) && (loByte < 127))
-            sprintf(lineBuf, "%c", loByte);
+            snprintf(lineBuf, sizeof(lineBuf), "%c", loByte);
          else
-            sprintf(lineBuf, ".");
-         strcat(asciiStr, lineBuf);
+            snprintf(lineBuf, sizeof(lineBuf), ".");
+         strlcat(asciiStr, lineBuf, sizeof(asciiStr));
       } else {
-         sprintf(lineBuf, "%02x ", buffer[address]);
-         strcat(dataStr, lineBuf);
+         snprintf(lineBuf, sizeof(lineBuf), "%02x ", buffer[address]);
+         strlcat(dataStr, lineBuf, sizeof(dataStr));
          if ((buffer[address] > 31) && (buffer[address] < 127))
-            sprintf(lineBuf, "%c", buffer[address]);
+            snprintf(lineBuf, sizeof(lineBuf), "%c", buffer[address]);
          else
-            sprintf(lineBuf, ".");
-         strcat(asciiStr, lineBuf);
+            snprintf(lineBuf, sizeof(lineBuf), ".");
+         strlcat(asciiStr, lineBuf, sizeof(asciiStr));
       }
    }
    printf("%06lx  %s  %s\n", address - addressPerLine, dataStr, asciiStr);
@@ -578,13 +579,13 @@
    char fileName[MAXLEN];
    char *fileNamePtr;
    
-   if (log.logging != 1)
+   if (logging.logging != 1)
       return(0);
 
    formatStr(commandStr, 6, MAXLEN);
-   strcpy(deviceName, device.name);
+   strlcpy(deviceName, device.name, sizeof(deviceName));
    if (strcmp(deviceName, "AT90(L)S2343 or Tiny22(L)") == 0)
-      strcpy(deviceName, "2343/Tiny22");
+      strlcpy(deviceName, "2343/Tiny22", sizeof(deviceName));
    formatStr(deviceName, 12, MAXLEN);
    queryBuf = malloc(FLASHBUF_UPPERLIMIT * sizeof (unsigned int));
    if (queryBuf == NULL) {
@@ -595,20 +596,24 @@
    curTime = time(NULL);
    locTime = localtime(&curTime);
 
-   if ((logPtr = fopen(log.logPath, "a")) == NULL) {
+   if ((logPtr = fopen(logging.logPath, "a")) == NULL) {
       free(queryBuf);
       return(1);
    }
    fprintf(logPtr, "%s %s ", deviceName, commandStr);
    if (strchr(commandStr, 'f') != NULL) {
-      strcpy(fileName, path);
+      strlcpy(fileName, path, sizeof(fileName));
       fileNamePtr = fileName;
       idx = strlen(fileName);
-      while (idx-- > 0 && fileName[idx] != '\\' && fileName[idx] != '/')
+#if defined(__WIN32__)
+      while (idx-- > 0 && fileName[idx] != '\\')
+#else
+      while (idx-- > 0 && fileName[idx] != '/')
+#endif
          fileNamePtr = &fileName[idx];
       formatStr(fileNamePtr, 14, MAXLEN - idx);
       fprintf(logPtr, "%s   ", fileNamePtr);
-      if (log.query) {
+      if (logging.query) {
          if (strchr(commandStr, 'p') != NULL) {
             readFlashArea(queryBuf, device.flashLimit);
             areaChksum = checksum(queryBuf, device.flashLimit);
@@ -667,17 +672,17 @@
    char deviceName[MAXLEN];
    char lBits[MAXLEN] = "";
 
-   if (log.logging != 1)
+   if (logging.logging != 1)
       return(0);
 
-   sprintf(lBits, "%02lx", strtol(lockBits, NULL, 2));
+   snprintf(lBits, sizeof(lBits), "%02lx", strtol(lockBits, NULL, 2));
 
-   strcpy(deviceName, device.name);
+   strlcpy(deviceName, device.name, sizeof(deviceName));
    formatStr(deviceName, 12, MAXLEN);
    curTime = time(NULL);
    locTime = localtime(&curTime);
 
-   if ((logPtr = fopen(log.logPath, "a")) == NULL)
+   if ((logPtr = fopen(logging.logPath, "a")) == NULL)
       return(1);
    fprintf(logPtr, "%s -L%s   ", deviceName, lBits);
    readFlashArea(buffer, device.flashLimit);
Index: dos_cpt.h
===================================================================
RCS file: /cvs/src/sp12/src/dos_cpt.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dos_cpt.h	6 Jan 2010 17:55:15 -0000	1.1
+++ dos_cpt.h	6 Jan 2010 18:39:36 -0000	1.2
@@ -20,7 +20,10 @@
 /* Kevin Towers can be reached by email: ktowers@omnexcontrols.com   */
 /* Ken Huntington can be reached by email: kenh@compmore.net         */
 
-#ifdef LINUX
+#ifndef _DOS_CPT_H
+#define _DOS_CPT_H
+
+#if defined (__linux__)
 
 #include <sys/io.h>
 #include <unistd.h>
@@ -30,9 +33,20 @@
 
 #define delay(a) usleep(a*1000)
 
-#else
+#define strlcpy(d, s, l) (strncpy(d, s, l), (d)[(l) - 1] = '\0')
+#define strlcat(d, s, l) strncat(d, s, (l) - strlen(d) - 1)
+
+#elif defined(__OpenBSD__)
+
+#include <machine/pio.h>
+#include <unistd.h>
+
+#define inportb(port) inb(port)
+#define outportb(port, data) outb(port, data)
 
-#ifdef WIN32
+#define delay(t) usleep((t) * 1000)
+
+#elif defined(__WIN32__)
 
 // these functions are in winnt.c
 void win_giveio(void);
@@ -44,10 +58,6 @@
 
 #include <dos.h>
 
-#endif  // WIN32
-#endif  // LINUX
-
-
-
-
+#endif
 
+#endif /* not _DOS_CPT_H */
Index: init.c
===================================================================
RCS file: /cvs/src/sp12/src/init.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- init.c	6 Jan 2010 17:55:15 -0000	1.1
+++ init.c	6 Jan 2010 18:59:30 -0000	1.3
@@ -140,7 +140,7 @@
 
 struct timeConsts timeConst;     
 struct device_info device;       
-struct logging log;
+struct logging logging;
 
 int portAddress;                 
 int portStatus;                  
@@ -307,11 +307,11 @@
    fprintf(rcPtr, "KANDA=%d\n", KandaMode);
    fprintf(rcPtr, "# Set the log path/file to log writes and locks.\n"); 
    fprintf(rcPtr, "# (less than 200 characters)\n"); 
-   fprintf(rcPtr, "LOGPATH=%s\n", log.logPath);
+   fprintf(rcPtr, "LOGPATH=%s\n", logging.logPath);
    fprintf(rcPtr, "# Set logging=1 to activate logging:\n"); 
-   fprintf(rcPtr, "LOGGING=%d\n", log.logging);
+   fprintf(rcPtr, "LOGGING=%d\n", logging.logging);
    fprintf(rcPtr, "# Set both logging and query=1 to always query writes:\n"); 
-   fprintf(rcPtr, "QUERY=%d\n", log.query);
+   fprintf(rcPtr, "QUERY=%d\n", logging.query);
    fprintf(rcPtr, "# Chip erase delay, 120ms ATMega, 20ms others:\n"); 
    fprintf(rcPtr, "CHIPERASE=%d\n", timeConst.chipErase);
    fprintf(rcPtr, "# Time constant for 200ms will be:\n"); 
@@ -371,25 +371,25 @@
    writeRetries = 0;
    timeConst.byteWriteAdjusted = 0;
    timeConst.pageWriteAdjusted = 0;
-   log.logging = 0;
-   log.query = 0;
-   strcpy(log.logPath, "sp12log.txt");
+   logging.logging = 0;
+   logging.query = 0;
+   strlcpy(logging.logPath, "sp12log.txt", sizeof(logging.logPath));
    KandaMode = 3;    /* if it remains 3 after reading _sp12rc, */
                      /* check how we were called               */
 
    if ((sp12rc = getenv("SP12")) != NULL) {
-      strcpy(rcPath, sp12rc);
-#ifdef LINUX
-      if (rcPath[strlen(rcPath)-1] != '/')
-          strcat (rcPath, "/");
-#else
+      strlcpy(rcPath, sp12rc, sizeof(rcPath));
+#if defined(__WIN32__)
       if (rcPath[strlen(rcPath)-1] != '\\')
-          strcat (rcPath, "\\");
+          strcat(rcPath, "\\", );
+#else
+      if (rcPath[strlen(rcPath)-1] != '/')
+          strlcat(rcPath, "/", sizeof(rcPath));
 #endif
       printf("Path to _sp12rc and _sp12dev: %s\n", rcPath);
-      strcat(rcPath, "_sp12rc");
+      strlcat(rcPath, "_sp12rc", sizeof(rcPath));
    } else {
-      strcpy(rcPath, "_sp12rc");
+      strlcpy(rcPath, "_sp12rc", sizeof(rcPath));
       printf("Path to _sp12rc and _sp12dev: Local directory\n");
    }
    if ((rcPtr = fopen(rcPath, "r")) != NULL) {
@@ -399,9 +399,9 @@
       while (fgets(rcLine, MAXLEN, rcPtr) != NULL) {
          sscanf(rcLine, "PORT=%x", &portAddress);
          sscanf(rcLine, "KANDA=%d", &KandaMode);
-         sscanf(rcLine, "LOGPATH=%s", log.logPath);
-         sscanf(rcLine, "LOGGING=%d", &log.logging);
-         sscanf(rcLine, "QUERY=%d", &log.query);
+         sscanf(rcLine, "LOGPATH=%s", logging.logPath);
+         sscanf(rcLine, "LOGGING=%d", &logging.logging);
+         sscanf(rcLine, "QUERY=%d", &logging.query);
          sscanf(rcLine, "RESETPULS=%ld", &timeConst.resetPuls);
          sscanf(rcLine, "CHIPERASE=%d", &timeConst.chipErase);
          sscanf(rcLine, "POWERON=%d", &timeConst.powerOn);
@@ -421,10 +421,13 @@
          fprintf(stderr, "Unable to open %s for writing.\n", rcPath);
          exit(1);
       }
-      if (strrchr(howWeAreCalled, '/') != NULL)
-         howWeAreCalled = (strrchr(howWeAreCalled, '/') + 1);
+#if defined(__WIN32__)
       if (strrchr(howWeAreCalled, '\\') != NULL)
          howWeAreCalled = (strrchr(howWeAreCalled, '\\') + 1);
+#else
+      if (strrchr(howWeAreCalled, '/') != NULL)
+         howWeAreCalled = (strrchr(howWeAreCalled, '/') + 1);
+#endif
       if (strchr(howWeAreCalled, 'k') == NULL) {
          KandaMode = 0;  /* default is sp12 cable/dongle */
       } else {
@@ -446,7 +449,7 @@
       || timeConst.programEnable == 0 || timeConst.chipErase == 0
       || timeConst.byteWrite == 0 || timeConst.powerOn == 0
       || timeConst.pageWrite == 0) {
-      fprintf(stderr, "Initialisation has failed (parallel port not found,\n");
+      fprintf(stderr, "Initialisation has failed (parallel port not found, ");
       fprintf(stderr, "or %s corrupt).\n", rcPath);
       exit(1);
    }
@@ -457,7 +460,7 @@
     */
    outportb(portAddress, 0x80);
    if (inportb(portAddress) != 0x80) {
-      fprintf(stderr, "Initialisation has failed (parallel port not\n");
+      fprintf(stderr, "Initialisation has failed (parallel port not ");
       fprintf(stderr, "responding, or %s corrupt).\n", rcPath);
       exit(1);
    } else {
@@ -470,10 +473,13 @@
    * or the cable/dongle as supplied with the 
    * Atmel/Kanda STK200/300 starter kits.
    */
-   if (strrchr(howWeAreCalled, '/') != NULL)
-      howWeAreCalled = (strrchr(howWeAreCalled, '/') + 1);
+#if defined(__WIN32__)
    if (strrchr(howWeAreCalled, '\\') != NULL)
       howWeAreCalled = (strrchr(howWeAreCalled, '\\') + 1);
+#else
+   if (strrchr(howWeAreCalled, '/') != NULL)
+      howWeAreCalled = (strrchr(howWeAreCalled, '/') + 1);
+#endif
    if (KandaMode == 0 || (KandaMode == 3 && strchr(howWeAreCalled, 'k') == NULL)) {
       SCK                = S_SCK;
       MOSI               = S_MOSI;
@@ -606,17 +612,17 @@
 
 
    if ((sp12dev = getenv("SP12")) != NULL) {
-      strcpy(rcPath, sp12dev);
-#ifdef LINUX
-      if (rcPath[strlen(rcPath)-1] != '/')
-          strcat (rcPath, "/");
-#else
+      strlcpy(rcPath, sp12dev, sizeof(rcPath));
+#if defined(__WIN32__)
       if (rcPath[strlen(rcPath)-1] != '\\')
-          strcat (rcPath, "\\");
+          strcat(rcPath, "\\");
+#else
+      if (rcPath[strlen(rcPath)-1] != '/')
+          strlcat(rcPath, "/", sizeof(rcPath));
 #endif
-      strcat(rcPath, "_sp12dev");
+      strlcat(rcPath, "_sp12dev", sizeof(rcPath));
    } else {
-      strcpy(rcPath, "_sp12dev");
+      strlcpy(rcPath, "_sp12dev", sizeof(rcPath));
    }
    
    if ((rcPtr = fopen(rcPath, "r")) == NULL) {
@@ -631,17 +637,17 @@
    deviceCode = deviceCode | device.sigByte_1;
    switch (device.sigByte_0) {
       case 0x1E:
-         strcpy(device.madeBy, "Atmel");
+         strlcpy(device.madeBy, "Atmel", sizeof(device.madeBy));
          break;
       default:
-         strcpy(device.madeBy, "an unknown manufacturer");
+         strlcpy(device.madeBy, "an unknown manufacturer", sizeof(device.madeBy));
    }
    begin = 0;
    iFlag = 0;
    found = 0;
-   strcpy(LOCK_MESSAGE, "");
-   strcpy(FUSES_MESSAGE, "");
-   strcpy(device.name, "unknown device, or no device");
+   strlcpy(LOCK_MESSAGE, "", sizeof(LOCK_MESSAGE));
+   strlcpy(FUSES_MESSAGE, "", sizeof(FUSES_MESSAGE));
+   strlcpy(device.name, "unknown device, or no device", sizeof(device.name));
    device.flashLimit = 0;
    device.eepromLimit = 0;
    device.pageMode = 0;
@@ -686,7 +692,7 @@
       }
 
       if (begin && sscanf(rcLine, "DEVICENAME = %[A-Z ()0-9a-z]", rawLine) == 1) {
-         strcpy(device.name, rawLine);
+         strlcpy(device.name, rawLine, sizeof(device.name));
       }
       if (begin && sscanf(rcLine, "FLASHSIZE = %i", &iNum) == 1) {
          device.flashLimit = iNum;
@@ -813,17 +819,17 @@
    int found = 0;
 
    if ((sp12dev = getenv("SP12")) != NULL) {
-      strcpy(rcPath, sp12dev);
-#ifdef LINUX
-      if (rcPath[strlen(rcPath)-1] != '/')
-          strcat (rcPath, "/");
-#else
+      strlcpy(rcPath, sp12dev, sizeof(rcPath));
+#if defined(__WIN32__)
       if (rcPath[strlen(rcPath)-1] != '\\')
-          strcat (rcPath, "\\");
+          strcat(rcPath, "\\");
+#else
+      if (rcPath[strlen(rcPath)-1] != '/')
+          strlcat(rcPath, "/", sizeof(rcPath));
 #endif
-      strcat(rcPath, "_sp12dev");
+      strlcat(rcPath, "_sp12dev", sizeof(rcPath));
    } else {
-      strcpy(rcPath, "_sp12dev");
+      strlcpy(rcPath, "_sp12dev", sizeof(rcPath));
    }
    
    if ((rcPtr = fopen(rcPath, "r")) == NULL) {
Index: makefile
===================================================================
RCS file: makefile
diff -N makefile
--- makefile	6 Jan 2010 17:55:15 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,58 +0,0 @@
-#
-# Makefile for the Free Software Foundations gcc compiler
-# Optimize flag = 1 to achieve correct timing
-#
-CC=gcc
-LINK=gcc
-#
-# LINUX FLAGS
-CFLAGS=-c -O1 -Wall -DLINUX
-LFLAGS=-s -o
-TARGET=sp12
-ERASE=rm -f
-OBJECTS=sp12.o init.o flash.o device.o buffer.o eeprom.o
-
-# DOS FLAGS
-#CFLAGS=-c -O1 -Wall
-#LFLAGS=-lemu -s -o
-#TARGET=sp12.exe
-#ERASE=del
-#OBJECTS=sp12.o init.o flash.o device.o buffer.o eeprom.o
-
-# Win FLAGS - MingW
-#CFLAGS=-c -O1 -Wall -mwindows -mconsole
-#LFLAGS=-s -o
-#TARGET=sp12.exe
-#ERASE=del
-#OBJECTS=sp12.o init.o flash.o device.o buffer.o eeprom.o winnt.o
-
-all: $(TARGET)
-
-sp12.o: sp12.c
-	$(CC) $(CFLAGS) sp12.c
-
-init.o: init.c
-	$(CC) $(CFLAGS) init.c
-
-flash.o: flash.c
-	$(CC) $(CFLAGS) flash.c
-
-device.o: device.c
-	$(CC) $(CFLAGS) device.c
-
-buffer.o: buffer.c
-	$(CC) $(CFLAGS) buffer.c
-
-eeprom.o: eeprom.c
-	$(CC) $(CFLAGS) eeprom.c
-
-winnt.o: winnt.c
-	$(CC) $(CFLAGS) winnt.c
-   
-$(TARGET): makefile $(OBJECTS)
-	$(LINK) $(LFLAGS) $(TARGET) $(OBJECTS)
-
-clean:
-	$(ERASE) $(TARGET)
-	$(ERASE) *.o
-
Index: sp12.c
===================================================================
RCS file: /cvs/src/sp12/src/sp12.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sp12.c	6 Jan 2010 17:55:16 -0000	1.1
+++ sp12.c	6 Jan 2010 18:39:36 -0000	1.2
@@ -22,6 +22,11 @@
 /* Ken Huntington can be reached by email: kenh@compmore.net         */
 /* Artur Pundsack can be reached by email: ap@pa-tec.de          */
 
+#if defined(__OpenBSD__)
+#include <sys/types.h>
+#include <machine/sysarch.h>
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -222,7 +227,7 @@
       * on the third byte of PROGRAM_ENABLE.
       * Initiating contact at low speed
       */
-      strcpy(device.name, "AT90S1200(A)");
+      strlcpy(device.name, "AT90S1200(A)", sizeof(device.name));
       setSckTiming(0.1);
       enableSPI(1200);
       deviceCode = setDevicePars(initFlag, identifier);
@@ -811,22 +816,28 @@
    checksumPath[0] = '\0';
    sp12Start = clock();
 
-#ifdef LINUX
+#if defined(__WIN32__)
+   win_giveio ();                              // get access to I/O ports in Windows NT/2000/XP
+#else
    /*
     * Take control of LPT I/O ports
     */
+#if defined(__linux__)
    if (ioperm(0x278,3,1)) {perror("ioperm error at 0x278");exit(1);}
    if (ioperm(0x378,3,1)) {perror("ioperm error at 0x378");exit(1);}
    if (ioperm(0x3BC,3,1)) {perror("ioperm error at 0x3BC");exit(1);}
+#elif defined(__OpenBSD__)
+   if (i386_iopl(1) == -1) {
+      perror("i386_iopl error");
+      exit(1);
+   }
+#endif
+#endif
    /*
     * Revoke setuid/setguid-root status
     */
    setgid(getgid());
    setuid(getuid());
-#endif
-#ifdef WIN32
-   win_giveio ();                              // get access to I/O ports in Windows NT/2000/XP
-#endif
 
    /*
     * Check if something is on the command line, print usage message
@@ -866,15 +877,15 @@
             exitSp12(2);
          }
          if (checksumFlag && !readFlag && !writeFlag) {
-            strcpy(checksumPath, argv[idx]);
+            strlcpy(checksumPath, argv[idx], sizeof(checksumPath));
             pathAvailable = 1;
             processCommand();
          } else if (flashFlag) {
-            strcpy(flashPath, argv[idx]);
+            strlcpy(flashPath, argv[idx], sizeof(flashPath));
             pathAvailable = 1;
             processCommand();
          } else if (eepromFlag) {
-            strcpy(eepromPath, argv[idx]);
+            strlcpy(eepromPath, argv[idx], sizeof(eepromPath));
             pathAvailable = 1;
             processCommand();
          } else {
@@ -911,13 +922,13 @@
       }
       if (*argv[idx] == '-') {
          if (strchr(argv[idx], 'w') != NULL)
-            strcpy(commandStr, argv[idx]);
+            strlcpy(commandStr, argv[idx], sizeof(commandStr));
          while ((ascii = *++argv[idx]) != '\0') {
             switch(ascii) {
                case 'i':
                   if (strlen(argv[idx]) > 1) {
                      initFlag = 1;
-                     strcpy(identifier, ++argv[idx]);
+                     strlcpy(identifier, ++argv[idx], sizeof(identifier));
                      argv[idx][1] = '\0';
                   }
                   if (idx > 1) {
@@ -972,7 +983,7 @@
                case 'L':
                   if (strlen(argv[idx]) > 1 \
                         && (*(argv[idx] + 1) == '0' || *(argv[idx] + 1) == '1')) {
-                     strcpy(lockBits, ++argv[idx]);
+                     strlcpy(lockBits, ++argv[idx], sizeof(lockBits));
                      argv[idx][1] = '\0';
                   }
                   lockFlag = 1;
@@ -1019,7 +1030,7 @@
                case 'F':
                   if (strlen(argv[idx]) > 1 \
                         && (*(argv[idx] + 1) == '0' || *(argv[idx] + 1) == '1')) {
-                     strcpy(fusesBits, ++argv[idx]);
+                     strlcpy(fusesBits, ++argv[idx], sizeof(fusesBits));
                      argv[idx][1] = '\0';
                   }
                   fusesFlag = 1;
@@ -1027,7 +1038,7 @@
                case 'H':
                   if (strlen(argv[idx]) > 1 \
                         && (*(argv[idx] + 1) == '0' || *(argv[idx] + 1) == '1')) {
-                     strcpy(fusesBits, ++argv[idx]);
+                     strlcpy(fusesBits, ++argv[idx], sizeof(fusesBits));
                      argv[idx][1] = '\0';
                   }
                   highFFlag = 1;
@@ -1035,7 +1046,7 @@
                case 'X':
                   if (strlen(argv[idx]) > 1 \
                         && (*(argv[idx] + 1) == '0' || *(argv[idx] + 1) == '1')) {
-                     strcpy(fusesBits, ++argv[idx]);
+                     strlcpy(fusesBits, ++argv[idx], sizeof(fusesBits));
                      argv[idx][1] = '\0';
                   }
                   extdFFlag = 1;
Index: sp12.h
===================================================================
RCS file: /cvs/src/sp12/src/sp12.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sp12.h	6 Jan 2010 17:55:16 -0000	1.1
+++ sp12.h	6 Jan 2010 18:39:36 -0000	1.2
@@ -22,6 +22,9 @@
 /* Ken Huntington can be reached by email: kenh@compmore.net         */
 /* Artur Pundsack can be reached by email: ap@pa-tec.de          */
 
+#ifndef _SP12_H
+#define _SP12_H
+
 #define WORDLEN                 16
 #define DATALEN                 5
 #define FLASH_DATAPTR           6
@@ -184,7 +187,7 @@
 
 extern struct timeConsts timeConst;
 extern struct device_info device;
-extern struct logging log;
+extern struct logging logging;
 
 extern int portAddress;
 extern int portStatus;
@@ -518,3 +521,4 @@
 
 void readEepromArea(unsigned int EepromBuf[], long bufLimit);
  
+#endif /* not _SP12_H */

