summaryrefslogtreecommitdiff
path: root/src/sp12.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp12.c')
-rw-r--r--src/sp12.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/sp12.c b/src/sp12.c
index 738f404..c0c9139 100644
--- a/src/sp12.c
+++ b/src/sp12.c
@@ -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 @@ void processCommand(void) {
* 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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
}
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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 @@ int main(int argc, char *argv[])
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;