diff crashRun.c @ 684:369c59b10266

ported crasRun to OpenBSD
author thomask
date Sun, 25 Sep 2005 17:50:06 +0000
parents 7b5efee9d724
children 528649416e9d
line wrap: on
line diff
--- a/crashRun.c	Sun Sep 25 06:32:59 2005 +0000
+++ b/crashRun.c	Sun Sep 25 17:50:06 2005 +0000
@@ -3,7 +3,7 @@
  *
  * Copyright (C)
  *		2005 Thomas Kuehne <thomas@kuehne.cn>
- *		2005 Anders F Björklund <afb@algonet.se>
+ *		2005 Anders F Björklund <afb@algonet.se>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -39,7 +39,7 @@
 #define USE_POSIX
 #endif
 
-#ifdef linux
+#if defined(linux) || defined(__FreeBsd__) || defined(__OpenBSD__)
 #define USE_POSIX
 #endif
 
@@ -47,10 +47,6 @@
 #define USE_POSIX
 #endif
 
-#ifdef __FreeBSD__
-#define USE_POSIX
-#endif
-
 #if !defined(USE_POSIX) && \
 	(defined(WINDOWS) || defined(WIN) || defined(WINVER) || defined(WIN32))
 #define USE_WINDOWS
@@ -216,9 +212,11 @@
 }
 
 char* reconstructCmd(int argc, char** argv){
-	int cmdLen=1;
-	int i;
+	size_t cmdLen=1;
+	size_t tmpLen;
+	size_t i;
 	char* cmd;
+	char* tmp;
 
 	for(i=0; i<argc; i++){
 		cmdLen+=strlen(argv[i]);
@@ -227,11 +225,12 @@
 
 	cmd = (char*)malloc(cmdLen);
 	*cmd = '\x00';
+	tmp = cmd;
 
 	for(i=0; i<argc; i++){
-		strcat(cmd, "\"");
-		strcat(cmd, argv[i]);
-		strcat(cmd, "\" ");
+		tmpLen = snprintf(tmp, cmdLen, "\"%s\" ", argv[i]);
+		tmp += tmpLen;
+		cmdLen -= tmpLen;
 	}
 	return cmd;
 }