More work on OpenBSD port, it's need more work to be complete :-/

git-svn-id: svn://localhost/gambas/trunk@913 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Laurent Carlier 2008-01-05 01:18:28 +00:00
parent 8a7e5a6c32
commit 19bf23a739
19 changed files with 253 additions and 77 deletions

View File

@ -1079,7 +1079,11 @@ static void output_debug_filename(void)
if (JOB->name[0] == '/')
{
#ifdef OS_OPENBSD
strlcpy(path, JOB->name, sizeof(path));
#else
strcpy(path, JOB->name);
#endif
}
else
{
@ -1087,8 +1091,11 @@ static void output_debug_filename(void)
n = strlen(path);
if (path[n - 1] != '/')
#ifdef OS_OPENBSD
strlcpy(&path[n], "/", sizeof(path)-n);
#else
strcpy(&path[n], "/");
#endif
strcat(&path[n], JOB->name);
}

View File

@ -160,8 +160,13 @@ static void init(void)
strncpy(_root, FILE_get_dir(FILE_get_dir(path)), MAX_PATH);
}
#ifdef OS_OPENBSD
strlcpy(_lib_path, FILE_cat(_root, "lib/gambas" GAMBAS_VERSION_STRING, NULL), sizeof(_lib_path));
strlcpy(_info_path, FILE_cat(_root, "share/gambas" GAMBAS_VERSION_STRING "/info", NULL), sizeof(_info_path));
#else
strcpy(_lib_path, FILE_cat(_root, "lib/gambas" GAMBAS_VERSION_STRING, NULL));
strcpy(_info_path, FILE_cat(_root, "share/gambas" GAMBAS_VERSION_STRING "/info", NULL));
#endif
if (lt_dlinit())
error(TRUE, "Cannot initialize plug-in management: %s", lt_dlerror());

View File

@ -469,7 +469,7 @@ PUBLIC void ERROR_save(ERROR_INFO *save)
save->backtrace = ERROR_info.backtrace;
ERROR_info.backtrace = NULL;
#ifdef OS_OPENBSD
strlcpy(save->msg, ERROR_info.msg, MAX_ERROR_MSG+1);
strlcpy(save->msg, ERROR_info.msg, sizeof(ERROR_info.msg));
#else
strcpy(save->msg, ERROR_info.msg);
#endif
@ -486,7 +486,7 @@ PUBLIC void ERROR_restore(ERROR_INFO *save)
ERROR_info.backtrace = save->backtrace;
save->backtrace = NULL;
#ifdef OS_OPENBSD
strlcpy(ERROR_info.msg, save->msg, MAX_ERROR_MSG+1);
strlcpy(ERROR_info.msg, save->msg, sizeof(ERROR_info.msg));
#else
strcpy(ERROR_info.msg, save->msg);
#endif

View File

@ -717,9 +717,14 @@ PUBLIC void *GB_GetClassInterface(void *_class, const char *_name)
CLASS_load(class);
#ifdef OS_OPENBSD
strlcpy(name, "_@", len+4);
strlcat(name, _name, len+4);
#else
strcpy(name, "_@");
strcat(name, _name);
#endif
index = CLASS_find_symbol(class, name);
if (index == NO_SYMBOL)
goto __NOT_FOUND;
@ -1586,7 +1591,11 @@ PUBLIC char *GB_RealFileName(const char *name, int len)
temp = FILE_make_temp(NULL, NULL);
STRING_new_temp(&real, NULL, strlen(temp) + strlen(path) + strlen("/data/"));
#ifdef OS_OPENBSD
snprintf(real, strlen(temp) + strlen(path) + strlen("/data/"), "%s/data/%s", temp, path);
#else
sprintf(real, "%s/data/%s", temp, path);
#endif
if (!FILE_exist(real))
{

View File

@ -292,7 +292,11 @@ static void init_again(int old_pid)
char old[MAX_PATH];
FILE_remove_temp_file();
#ifdef OS_OPENBSD
snprintf(old, sizeof(old),FILE_TEMP_DIR, getuid(), old_pid);
#else
sprintf(old, FILE_TEMP_DIR, getuid(), old_pid);
#endif
rename(old, FILE_make_temp(NULL, NULL));
}

View File

@ -722,8 +722,11 @@ CLASS *CLASS_replace_global(const char *name)
len = strlen(name);
ALLOC(&new_name, len + 2, "CLASS_replace_global");
#ifdef OS_OPENBSD
snprintf(new_name, len+2, ">%s", name);
#else
sprintf(new_name, ">%s", name);
#endif
new_class = CLASS_replace_global(new_name);
FREE(&new_name, "CLASS_replace_global");

View File

@ -87,8 +87,12 @@ PUBLIC const char *DEBUG_get_position(CLASS *cp, FUNCTION *fp, PCODE *pc)
line);
return buffer;
#else
#ifdef OS_OPENBSD
snprintf(COMMON_buffer, COMMON_BUF_MAX, "%.64s.%.64s.%d",
#else
sprintf(COMMON_buffer, "%.64s.%.64s.%d",
#endif
cp ? cp->name : "?",
(fp && fp->debug) ? fp->debug->name : "?",
line);

View File

@ -87,7 +87,11 @@ static void *get_symbol(LIBRARY *lib, const char *symbol, bool err)
sym = lt_dlsym(lib->handle, symbol);
if (sym == NULL && err)
{
#ifdef OS_OPENBSD
strlcpy(COMMON_buffer, lt_dlerror(), COMMON_BUF_MAX);
#else
strcpy(COMMON_buffer, lt_dlerror());
#endif
lt_dlclose(lib->handle);
lib->handle = NULL;
THROW(E_LIBRARY, lib->name, COMMON_buffer);
@ -149,10 +153,18 @@ static void add_preload(char **env, const char *lib)
{
org = getenv("LD_PRELOAD");
if (org && *org)
*env += sprintf(*env, "%s ", org);
#ifdef OS_OPENBSD
*env += snprintf(*env, COMMON_BUF_MAX, "%s ", org);
#else
*env += sprintf(*env, "%s ", org);
#endif
}
#ifdef OS_OPENBSD
*env += snprintf(*env, &COMMON_buffer[COMMON_BUF_MAX] - *env, "%s ", lib);
#else
*env += sprintf(*env, "%s ", lib);
#endif
}
@ -196,7 +208,11 @@ PUBLIC void LIBRARY_preload(const char *file, char **argv)
if (*file == '/')
{
#ifdef OS_OPENBSD
strlcpy(dir, file, sizeof(dir));
#else
strcpy(dir, file);
#endif
}
else
{
@ -213,7 +229,11 @@ PUBLIC void LIBRARY_preload(const char *file, char **argv)
if (path == NULL)
goto _PANIC;
#ifdef OS_OPENBSD
strlcpy(dir, path, sizeof(dir));
#else
strcpy(dir, path);
#endif
}
file = FILE_cat(dir, ".project", NULL);
@ -349,8 +369,11 @@ PUBLIC void LIBRARY_get_interface(LIBRARY *lib, long version, void *iface)
symbol[i] = c;
}
#ifdef OS_OPENBSD
snprintf(&symbol[len], sizeof(symbol)-len, "_%ld", version);
#else
sprintf(&symbol[len], "_%ld", version);
#endif
copy_interface((long *)get_symbol(lib, symbol, TRUE), (long *)iface);
}
@ -416,9 +439,17 @@ PUBLIC void LIBRARY_load(LIBRARY *lib)
return;
path = FILE_buffer();
#ifdef OS_OPENBSD
snprintf(path, PATH_MAX, LIB_PATTERN, COMPONENT_path, lib->name);
#else
sprintf(path, LIB_PATTERN, COMPONENT_path, lib->name);
#endif
if (!FILE_exist(path))
#ifdef OS_OPENBSD
snprintf(path, PATH_MAX, LIB_PATTERN, COMPONENT_user_path, lib->name);
#else
sprintf(path, LIB_PATTERN, COMPONENT_user_path, lib->name);
#endif
#ifndef DONT_USE_LTDL
/* no more available in libltld ?

View File

@ -83,14 +83,22 @@ __BYTE:
__SHORT:
__INTEGER:
#ifdef OS_OPENBSD
*len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "%d", value->_integer.value);
#else
*len = sprintf(COMMON_buffer, "%d", value->_integer.value);
#endif
*addr = COMMON_buffer;
return;
__LONG:
#ifdef OS_OPENBSD
*len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "%lld", value->_long.value);
#else
*len = sprintf(COMMON_buffer, "%lld", value->_long.value);
#endif
*addr = COMMON_buffer;
return;
@ -141,7 +149,11 @@ __STRING:
else if (c == 9)
*d++ = 't';
else
#ifdef OS_OPENBSD
d += snprintf(d, &COMMON_buffer[COMMON_BUF_MAX]-d, "x%02X", c);
#else
d += sprintf(d, "x%02X", c);
#endif
}
else if (c == '\"')
{

View File

@ -71,7 +71,11 @@ static void raise_error(const char *msg)
{
char line[16];
#ifdef OS_OPENBSD
snprintf(line, sizeof(line), "%d", project_line);
#else
sprintf(line, "%d", project_line);
#endif
THROW(E_PROJECT, line, msg);
}

View File

@ -500,7 +500,7 @@ PUBLIC int STRING_conv(char **result, const char *str, int len, const char *src,
out = COMMON_buffer;
out_len = COMMON_BUF_MAX;
#if defined(OS_SOLARIS) || defined(OS_FREEBSD)
#if defined(OS_SOLARIS) || defined(OS_FREEBSD) || defined(OS_OPENBSD)
ret = iconv(handle, &in, &in_len, &out, &out_len);
#else
ret = iconv(handle, (char **)&in, &in_len, &out, &out_len);

View File

@ -311,14 +311,22 @@ __c2s:
__h2s:
__i2s:
#ifdef OS_OPENBSD
len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "%d", value->_integer.value);
#else
len = sprintf(COMMON_buffer, "%d", value->_integer.value);
#endif
STRING_new_temp_value(value, COMMON_buffer, len);
BORROW(value);
return;
__l2s:
#ifdef OS_OPENBSD
len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "%lld", value->_long.value);
#else
len = sprintf(COMMON_buffer, "%lld", value->_long.value);
#endif
STRING_new_temp_value(value, COMMON_buffer, len);
BORROW(value);
return;
@ -996,14 +1004,22 @@ __BYTE:
__SHORT:
__INTEGER:
#ifdef OS_OPENBSD
*len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "%d", value->_integer.value);
#else
*len = sprintf(COMMON_buffer, "%d", value->_integer.value);
#endif
*addr = COMMON_buffer;
return;
__LONG:
#ifdef OS_OPENBSD
*len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "%lld", value->_long.value);
#else
*len = sprintf(COMMON_buffer, "%lld", value->_long.value);
#endif
*addr = COMMON_buffer;
return;
@ -1030,7 +1046,11 @@ __OBJECT:
if (VALUE_is_null(value))
goto __NULL;
#ifdef OS_OPENBSD
*len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "(%s %p)", OBJECT_class(value->_object.object)->name, value->_object.object);
#else
*len = sprintf(COMMON_buffer, "(%s %p)", OBJECT_class(value->_object.object)->name, value->_object.object);
#endif
*addr = COMMON_buffer;
return;
@ -1045,14 +1065,22 @@ __VOID:
__CLASS:
#ifdef OS_OPENBSD
*len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "(Class %s)", value->_class.class->name);
#else
*len = sprintf(COMMON_buffer, "(Class %s)", value->_class.class->name);
#endif
*addr = COMMON_buffer;
return;
__ARRAY:
__FUNCTION:
#ifdef OS_OPENBSD
*len = snprintf(COMMON_buffer, COMMON_BUF_MAX, "(%s ?)", TYPE_get_name(value->type));
#else
*len = sprintf(COMMON_buffer, "(%s ?)", TYPE_get_name(value->type));
#endif
*addr = COMMON_buffer;
/*THROW(E_TYPE, TYPE_get_name(T_STRING), TYPE_get_name(value->type));*/

View File

@ -7,7 +7,7 @@
## unlimited permission to copy and/or distribute it, with or without
## modifications, as long as this notice is preserved.
## serial 48 AC_PROG_LIBTOOL
# serial 48 AC_PROG_LIBTOOL
# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
@ -1572,27 +1572,10 @@ linux*)
# before this can be enabled.
hardcode_into_libs=yes
# find out which ABI we are using
libsuff=
case "$host_cpu" in
x86_64*|s390x*|powerpc64*)
echo '[#]line __oline__ "configure"' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case `/usr/bin/file conftest.$ac_objext` in
*64-bit*)
libsuff=64
sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
;;
esac
fi
rm -rf conftest*
;;
esac
# Append ld.so.conf contents to the search path
if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
fi
# We used to test for /lib/ld.so.1 and disable shared libraries on
@ -3408,16 +3391,20 @@ case $host_os in
_LT_AC_TAGVAR(ld_shlibs, $1)=no
;;
openbsd*)
_LT_AC_TAGVAR(hardcode_direct, $1)=yes
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
if test -f /usr/libexec/ld.so; then
_LT_AC_TAGVAR(hardcode_direct, $1)=yes
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
_LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
fi
output_verbose_link_cmd='echo'
else
_LT_AC_TAGVAR(ld_shlibs, $1)=no
fi
output_verbose_link_cmd='echo'
;;
osf3*)
case $cc_basename in
@ -4044,7 +4031,6 @@ CC=${GCJ-"gcj"}
compiler=$CC
_LT_AC_TAGVAR(compiler, $1)=$CC
_LT_CC_BASENAME([$compiler])
_LT_AC_TAGVAR(LD, $1)="$LD"
# GCJ did not exist at the time GCC didn't implicitly link libc in.
_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
@ -4312,9 +4298,6 @@ CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
# Is the compiler the GNU C compiler?
with_gcc=$_LT_AC_TAGVAR(GCC, $1)
gcc_dir=\`gcc -print-file-name=. | $SED 's,/\.$,,'\`
gcc_ver=\`gcc -dumpversion\`
# An ERE matcher.
EGREP=$lt_EGREP
@ -4448,11 +4431,11 @@ striplib=$lt_striplib
# Dependencies to place before the objects being linked to create a
# shared library.
predep_objects=\`echo $lt_[]_LT_AC_TAGVAR(predep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
# Dependencies to place after the objects being linked to create a
# shared library.
postdep_objects=\`echo $lt_[]_LT_AC_TAGVAR(postdep_objects, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
# Dependencies to place before the objects being linked to create a
# shared library.
@ -4464,7 +4447,7 @@ postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
# The library search path used internally by the compiler when linking
# a shared library.
compiler_lib_search_path=\`echo $lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
# Method to check whether dependent libraries are shared objects.
deplibs_check_method=$lt_deplibs_check_method
@ -4544,7 +4527,7 @@ variables_saved_for_relink="$variables_saved_for_relink"
link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
# Compile-time system search path for libraries
sys_lib_search_path_spec=\`echo $lt_sys_lib_search_path_spec | \$SED -e "s@\${gcc_dir}@\\\${gcc_dir}@g;s@\${gcc_ver}@\\\${gcc_ver}@g"\`
sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
# Run-time system search path for libraries
sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
@ -6033,24 +6016,28 @@ _LT_EOF
;;
openbsd*)
_LT_AC_TAGVAR(hardcode_direct, $1)=yes
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
if test -f /usr/libexec/ld.so; then
_LT_AC_TAGVAR(hardcode_direct, $1)=yes
_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
else
case $host_os in
openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
;;
*)
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
;;
esac
fi
else
case $host_os in
openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
_LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
;;
*)
_LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
;;
esac
_LT_AC_TAGVAR(ld_shlibs, $1)=no
fi
;;
@ -6423,7 +6410,7 @@ AC_MSG_RESULT([$SED])
## unlimited permission to copy and/or distribute it, with or without
## modifications, as long as this notice is preserved.
## serial 7 AC_LIB_LTDL
# serial 7 AC_LIB_LTDL
# AC_WITH_LTDL
# ------------

View File

@ -71,6 +71,19 @@ AC_SUBST([LIBTOOL_DEPS])
AC_LIB_LTDL
## ----------------- ##
## Check for OpenBSD ##
## ----------------- ##
AC_MSG_CHECKING(if target system is OpenBSD)
case "${host}" in
*-*-openbsd* )
AC_DEFINE(OS_OPENBSD, 1, [Target system is OpenBSD])
AC_MSG_RESULT(Yes)
;;
*)
AC_MSG_RESULT(No)
;;
esac
## -------- ##
## Outputs. ##

View File

@ -272,7 +272,11 @@ strdup(str)
tmp = LT_DLMALLOC (char, 1+ strlen (str));
if (tmp)
{
#ifdef OS_OPENBSD
strlcpy(tmp, str, strlen(str)+1);
#else
strcpy(tmp, str);
#endif
}
}
@ -894,7 +898,7 @@ static const char sys_search_path[] = LTDL_SYSSEARCHPATH;
(*lt_dlmutex_seterror_func) (errormsg); \
else lt_dllast_error = (errormsg); } LT_STMT_END
#define LT_DLMUTEX_GETERROR(errormsg) LT_STMT_START { \
if (lt_dlmutex_seterror_func) \
if (lt_dlmutex_geterror_func) \
(errormsg) = (*lt_dlmutex_geterror_func) (); \
else (errormsg) = lt_dllast_error; } LT_STMT_END
@ -2706,13 +2710,21 @@ foreach_dirinpath (search_path, base_name, func, data1, data2)
}
assert (filenamesize > lendir);
#ifdef OS_OPENBSD
strlcpy (filename, dir_name, filenamesize);
#else
strcpy (filename, dir_name);
#endif
if (base_name && *base_name)
{
if (filename[lendir -1] != '/')
filename[lendir++] = '/';
#ifdef OS_OPENBSD
strlcpy (filename, base_name, filenamesize-lendir);
#else
strcpy (filename +lendir, base_name);
#endif
}
if ((result = (*func) (filename, data1, data2)))
@ -3493,7 +3505,11 @@ lt_dlopenext (filename)
if (!tmp)
return 0;
#ifdef OS_OPENBSD
strlcpy (tmp, filename, len+LT_STRLEN(archive_ext)+1);
#else
strcpy (tmp, filename);
#endif
strcat (tmp, archive_ext);
errors = try_dlopen (&handle, tmp);
@ -3517,7 +3533,11 @@ lt_dlopenext (filename)
if (!tmp)
return 0;
#ifdef OS_OPENBSD
strlcpy (tmp, filename, len+LT_STRLEN(shlib_ext)+1);
#else
strcpy (tmp, filename);
#endif
}
else
{
@ -3653,7 +3673,11 @@ lt_argz_insertdir (pargz, pargz_len, dirnam, dp)
assert (buf);
#ifdef OS_OPENBSD
strlcpy (buf, dirnam, buf_len+1);
#else
strcpy (buf, dirnam);
#endif
strcat (buf, "/");
strncat (buf, dp->d_name, end_offset);
buf[buf_len] = LT_EOS_CHAR;
@ -3906,12 +3930,20 @@ lt_dlsym (handle, symbol)
/* this is a libtool module */
if (handle->loader->sym_prefix)
{
#ifdef OS_OPENBSD
strlcpy(sym, handle->loader->sym_prefix, lensym + LT_SYMBOL_OVERHEAD + 1);
#else
strcpy(sym, handle->loader->sym_prefix);
#endif
strcat(sym, handle->info.name);
}
else
{
#ifdef OS_OPENBSD
strlcpy(sym, handle->info.name, lensym + LT_SYMBOL_OVERHEAD + 1);
#else
strcpy(sym, handle->info.name);
#endif
}
strcat(sym, "_LTX_");
@ -3933,12 +3965,20 @@ lt_dlsym (handle, symbol)
/* otherwise try "symbol" */
if (handle->loader->sym_prefix)
{
#ifdef OS_OPENBSD
strlcpy(sym, handle->loader->sym_prefix, lensym + LT_SYMBOL_OVERHEAD + 1);
#else
strcpy(sym, handle->loader->sym_prefix);
#endif
strcat(sym, symbol);
}
else
{
#ifdef OS_OPENBSD
strlcpy(sym, symbol, lensym + LT_SYMBOL_OVERHEAD + 1);
#else
strcpy(sym, symbol);
#endif
}
address = handle->loader->find_sym (data, handle->module, sym);

View File

@ -258,8 +258,13 @@ PUBLIC bool ARCH_find(ARCH *arch, const char *path, int len_path, ARCH_FIND *fin
break;
sym = &arch->symbol[ind];
#ifdef OS_OPENBSD
len_tpath = snprintf(tpath2, sizeof(tpath2),"/%d:%s", ind, p + 1);
strlcpy(tpath, tpath2, sizeof(tpath));
#else
len_tpath = sprintf(tpath2, "/%d:%s", ind, p + 1);
strcpy(tpath, tpath2);
#endif
}
SYMBOL_find(arch->symbol, arch->header.n_symbol, sizeof(ARCH_SYMBOL), TF_NORMAL, tpath, len_tpath, 0, &ind);

View File

@ -131,15 +131,27 @@ PUBLIC char *FILE_make_temp(int *len, char *pattern)
if (len)
{
if (pattern)
#ifdef OS_OPENBSD
*len = snprintf(file_buffer, sizeof(file_buffer), FILE_TEMP_PATTERN, getuid(), getpid(), pattern);
#else
*len = sprintf(file_buffer, FILE_TEMP_PATTERN, getuid(), getpid(), pattern);
else
#endif
else
{
count++;
#ifdef OS_OPENBSD
*len = snprintf(file_buffer, sizeof(file_buffer), FILE_TEMP_FILE, getuid(), getpid(), count);
#else
*len = sprintf(file_buffer, FILE_TEMP_FILE, getuid(), getpid(), count);
#endif
}
}
else
#ifdef OS_OPENBSD
snprintf(file_buffer, sizeof(file_buffer), FILE_TEMP_DIR, getuid(), getpid());
#else
sprintf(file_buffer, FILE_TEMP_DIR, getuid(), getpid());
#endif
return file_buffer;
}
@ -168,9 +180,17 @@ PUBLIC void FILE_init(void)
{
FILE_remove_temp_file();
#ifdef OS_OPENBSD
snprintf(file_buffer, sizeof(file_buffer), FILE_TEMP_PREFIX, getuid());
#else
sprintf(file_buffer, FILE_TEMP_PREFIX, getuid());
#endif
mkdir(file_buffer, S_IRWXU);
#ifdef OS_OPENBSD
snprintf(file_buffer, sizeof(file_buffer), FILE_TEMP_DIR, getuid(), getpid());
#else
sprintf(file_buffer, FILE_TEMP_DIR, getuid(), getpid());
#endif
mkdir(file_buffer, S_IRWXU);
}
@ -281,7 +301,7 @@ PUBLIC const char *FILE_get_dir(const char *path)
if (file_buffer != path)
#ifdef OS_OPENBSD
strlcpy(file_buffer, path, PATH_MAX+16);
strlcpy(file_buffer, path, sizeof(file_buffer));
#else
strcpy(file_buffer, path);
#endif
@ -296,7 +316,7 @@ PUBLIC const char *FILE_get_dir(const char *path)
if (file_buffer[0] == 0 && path[0] == '/')
#ifdef OS_OPENBSD
strlcpy(file_buffer, "/", PATH_MAX+16);
strlcpy(file_buffer, "/", sizeof(file_buffer));
#else
strcpy(file_buffer, "/");
#endif
@ -342,7 +362,7 @@ PUBLIC const char *FILE_set_ext(const char *path, const char *ext)
if (path != file_buffer)
{
#ifdef OS_OPENBSD
strlcpy(file_buffer, path, PATH_MAX+16);
strlcpy(file_buffer, path, sizeof(file_buffer));
#else
strcpy(file_buffer, path);
#endif
@ -370,7 +390,7 @@ PUBLIC const char *FILE_set_ext(const char *path, const char *ext)
ext++;
#ifdef OS_OPENBSD
strlcpy(p, ext, strlen(p));
strlcpy(p, ext, (&file_buffer[MAX_PATH] - p));
#else
strcpy(p, ext);
#endif
@ -388,7 +408,7 @@ PUBLIC const char *FILE_get_basename(const char *path)
if (file_buffer != path)
#ifdef OS_OPENBSD
strlcpy(file_buffer, path, PATH_MAX+16);
strlcpy(file_buffer, path, sizeof(file_buffer));
#else
strcpy(file_buffer, path);
#endif
@ -555,7 +575,7 @@ PUBLIC bool FILE_dir_next(char **path, int *len)
if (file_attr)
{
#ifdef OS_OPENBSD
strlcpy(p, file_path, strlen(p));
strlcpy(p, file_path, &file_buffer[MAX_PATH] - p);
#else
strcpy(p, file_path);
#endif
@ -579,7 +599,7 @@ PUBLIC bool FILE_dir_next(char **path, int *len)
if (file_attr)
{
#ifdef OS_OPENBSD
strlcpy(p, entry->d_name, strlen(p));
strlcpy(p, entry->d_name, &file_buffer[MAX_PATH] - p);
#else
strcpy(p, entry->d_name);
#endif
@ -697,7 +717,7 @@ PUBLIC void FILE_make_path_dir(const char *path)
if (path != file_buffer)
#ifdef OS_OPENBSD
strlcpy(file_buffer, path, MAX_PATH+16);
strlcpy(file_buffer, path, sizeof(file_buffer));
#else
strcpy(file_buffer, path);
#endif

View File

@ -47,7 +47,11 @@ int setenv(const char *name, const char *value, int overwrite)
if (!env)
return (-1);
#ifdef OS_OPENBSD
strlcpy(env, name, strlen(name) + strlen(value) + 2);
#else
strcpy(env, name);
#endif
strcat(env, "=");
strcat(env, value);
putenv(env);

View File

@ -241,8 +241,8 @@ PUBLIC boolean SYMBOL_find(void *symbol, int n_symbol, size_t s_symbol, int flag
ERROR_panic("SYMBOL_find: prefixed symbol too long");
#ifdef OS_OPENBSD
strlcpy(_buffer, prefix, MAX_SYMBOL_LEN+1);
strlcpy(&_buffer[len_prefix], name, MAX_SYMBOL_LEN+1);
strlcpy(_buffer, prefix, sizeof(_buffer));
strlcpy(&_buffer[len_prefix], name, sizeof(_buffer)-len_prefix);
#else
strcpy(_buffer, prefix);
strcpy(&_buffer[len_prefix], name);
@ -288,8 +288,8 @@ PUBLIC boolean SYMBOL_find_old(void *symbol, int n_symbol, size_t s_symbol, int
ERROR_panic("SYMBOL_find: prefixed symbol too long");
#ifdef OS_OPENBSD
strlcpy(_buffer, prefix, MAX_SYMBOL_LEN+1);
strlcpy(&_buffer[len_prefix], name, MAX_SYMBOL_LEN+1);
strlcpy(_buffer, prefix, sizeof(_buffer));
strlcpy(&_buffer[len_prefix], name, sizeof(_buffer)-len_prefix);
#else
strcpy(_buffer, prefix);
strcpy(&_buffer[len_prefix], name);
@ -332,7 +332,7 @@ PUBLIC const char *TABLE_get_symbol_name(TABLE *table, int index)
if ((index < 0) || (index >= ARRAY_count(table->symbol)))
#ifdef OS_OPENBSD
strlcpy(_buffer, "?", MAX_SYMBOL_LEN+1);
strlcpy(_buffer, "?", sizeof(_buffer));
#else
strcpy(_buffer, "?");
#endif