Compare commits

...

4 Commits

Author SHA1 Message Date
Juhani Krekelä df0b7c07d0 Add sortix.c to the build system 2021-11-28 00:41:53 +02:00
Juhani Krekelä 6106cbd49a Add .gitignore 2021-11-27 23:37:06 +02:00
Juhani Krekelä 30d01f4321 Sortix patches 2021-10-03 23:32:32 +03:00
Juhani Krekelä 11fa5e22e3 sprintf → snprintf 2021-10-03 23:30:55 +03:00
26 changed files with 287 additions and 92 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
*.o
links
Makefile
config.cache
config.h
config.log
config.status
stamp-h

View File

@ -24,7 +24,7 @@ if JAVASCRIPT
links_LDADD=builtin.o context.o ipret.o javascr.o javascript.o md5.o md5hl.o ns.o pomocny.o regexp.o
endif
links_SOURCES=af_unix.c auth.c beos.c bfu.c block.c bookmark.c cache.c charsets.c compress.c connect.c cookies.c data.c default.c dip.c directfb.c dither.c dns.c dos.c drivers.c error.c file.c finger.c fn_impl.c fontconf.c font_inc.c framebuf.c freetype.c ftp.c gif.c grx.c hpux.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c listedit.c lru.c mailto.c main.c memory.c menu.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c string.c suffix.c svg.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c vms.c x.c xbm.c beos.h bits.h cfg.h codepage.h com-defs.h config-vms.h dfb_cur.h hpux.h language.h links.h os_dep.h os_depx.h setup.h arrow.inc certs.inc codepage.inc entity.inc fbcommon.inc language.inc links_ic.inc locase.inc suffix.inc suffix_x.inc uni_7b.inc upcase.inc vpipe.inc
links_SOURCES=af_unix.c auth.c beos.c bfu.c block.c bookmark.c cache.c charsets.c compress.c connect.c cookies.c data.c default.c dip.c directfb.c dither.c dns.c dos.c drivers.c error.c file.c finger.c fn_impl.c fontconf.c font_inc.c framebuf.c freetype.c ftp.c gif.c grx.c hpux.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c listedit.c lru.c mailto.c main.c memory.c menu.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c string.c suffix.c svg.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c vms.c x.c xbm.c beos.h bits.h cfg.h codepage.h com-defs.h config-vms.h dfb_cur.h hpux.h language.h links.h os_dep.h os_depx.h setup.h arrow.inc certs.inc codepage.inc entity.inc fbcommon.inc language.inc links_ic.inc locase.inc suffix.inc suffix_x.inc uni_7b.inc upcase.inc vpipe.inc sortix.c
# builtin.c context.c ipret.c javascr.c javascript.c md5.c md5hl.c ns.c pomocny.c regexp.c md5.h ns.h struct.h tree.h typy.h ipret.h javascript.h builtin.h builtin_keys.h
dist-hook:

View File

@ -35,8 +35,6 @@ mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
@ -78,7 +76,7 @@ bin_PROGRAMS = links
@HAIKU_GR_TRUE@links_LDADD = haiku.o
@JAVASCRIPT_TRUE@links_LDADD = builtin.o context.o ipret.o javascr.o javascript.o md5.o md5hl.o ns.o pomocny.o regexp.o
links_SOURCES = af_unix.c auth.c beos.c bfu.c block.c bookmark.c cache.c charsets.c compress.c connect.c cookies.c data.c default.c dip.c directfb.c dither.c dns.c dos.c drivers.c error.c file.c finger.c fn_impl.c fontconf.c font_inc.c framebuf.c freetype.c ftp.c gif.c grx.c hpux.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c listedit.c lru.c mailto.c main.c memory.c menu.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c string.c suffix.c svg.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c vms.c x.c xbm.c beos.h bits.h cfg.h codepage.h com-defs.h config-vms.h dfb_cur.h hpux.h language.h links.h os_dep.h os_depx.h setup.h arrow.inc certs.inc codepage.inc entity.inc fbcommon.inc language.inc links_ic.inc locase.inc suffix.inc suffix_x.inc uni_7b.inc upcase.inc vpipe.inc
links_SOURCES = af_unix.c auth.c beos.c bfu.c block.c bookmark.c cache.c charsets.c compress.c connect.c cookies.c data.c default.c dip.c directfb.c dither.c dns.c dos.c drivers.c error.c file.c finger.c fn_impl.c fontconf.c font_inc.c framebuf.c freetype.c ftp.c gif.c grx.c hpux.c html.c html_gr.c html_r.c html_tbl.c http.c https.c img.c imgcache.c jpeg.c jsint.c kbd.c language.c listedit.c lru.c mailto.c main.c memory.c menu.c objreq.c os_dep.c pmshell.c png.c sched.c select.c session.c smb.c string.c suffix.c svg.c svgalib.c terminal.c tiff.c types.c url.c view.c view_gr.c vms.c x.c xbm.c beos.h bits.h cfg.h codepage.h com-defs.h config-vms.h dfb_cur.h hpux.h language.h links.h os_dep.h os_depx.h setup.h arrow.inc certs.inc codepage.inc entity.inc fbcommon.inc language.inc links_ic.inc locase.inc suffix.inc suffix_x.inc uni_7b.inc upcase.inc vpipe.inc sortix.c
CXXFLAGS = @CXXFLAGS@
@ -102,7 +100,7 @@ hpux.o html.o html_gr.o html_r.o html_tbl.o http.o https.o img.o \
imgcache.o jpeg.o jsint.o kbd.o language.o listedit.o lru.o mailto.o \
main.o memory.o menu.o objreq.o os_dep.o pmshell.o png.o sched.o \
select.o session.o smb.o string.o suffix.o svg.o svgalib.o terminal.o \
tiff.o types.o url.o view.o view_gr.o vms.o x.o xbm.o
tiff.o types.o url.o view.o view_gr.o vms.o x.o xbm.o sortix.o
@ATHEOS_GR_TRUE@links_DEPENDENCIES = atheos.o
@JAVASCRIPT_TRUE@links_DEPENDENCIES = builtin.o context.o ipret.o \
@JAVASCRIPT_TRUE@javascr.o javascript.o md5.o md5hl.o ns.o pomocny.o \
@ -459,6 +457,8 @@ session.o: session.c links.h cfg.h config.h com-defs.h os_dep.h \
os_depx.h setup.h language.h codepage.h
smb.o: smb.c links.h cfg.h config.h com-defs.h os_dep.h os_depx.h \
setup.h language.h codepage.h
sortix.o: sortix.c links.h cfg.h config.h com-defs.h os_dep.h os_depx.h \
setup.h language.h codepage.h
string.o: string.c links.h cfg.h config.h com-defs.h os_dep.h os_depx.h \
setup.h language.h codepage.h
suffix.o: suffix.c links.h cfg.h config.h com-defs.h os_dep.h os_depx.h \

View File

@ -229,6 +229,9 @@
/* */
#undef GRDRV_GRX
/* */
#undef GRDRV_SORTIX
/* Have freetype */
#undef HAVE_FREETYPE

View File

@ -205,6 +205,7 @@ int bind_to_af_unix(unsigned char *name)
#endif
EINTRLOOP(rs, bind(s_unix_fd, &s_unix.s, s_unix_l));
if (rs) {
attempt_connect:
/*debug("bind: %d, %s", errno, strerror(errno));*/
if (af == PF_INET && errno == EADDRNOTAVAIL) {
/* do not try to connect if the user has not configured loopback interface */
@ -217,7 +218,7 @@ int bind_to_af_unix(unsigned char *name)
#if defined(SOL_SOCKET) && defined(SO_REUSEADDR)
EINTRLOOP(rs, setsockopt(s_unix_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&a1, sizeof a1));
#endif
EINTRLOOP(rs, connect(s_unix_fd, &s_unix.s, s_unix_l));
rs = blocking_connect(s_unix_fd, &s_unix.s, s_unix_l);
if (rs) {
retry:
/*debug("connect: %d, %s", errno, strerror(errno));*/
@ -255,6 +256,7 @@ retry_unlink:
}
EINTRLOOP(rs, listen(s_unix_fd, 100));
if (rs) {
if (errno == EADDRINUSE) goto attempt_connect;
error("ERROR: listen failed: %d", errno);
close_and_fail:
EINTRLOOP(rs, close(s_unix_fd));

View File

@ -215,6 +215,9 @@
/* Define if you have the dirfd function. */
#undef HAVE_DIRFD
/* Define if you have the <display.h> header file. */
#undef HAVE_DISPLAY_H
/* Define if you have the event_base_free function. */
#undef HAVE_EVENT_BASE_FREE
@ -596,6 +599,9 @@
/* Define if you have the <fontconfig/fontconfig.h> header file. */
#undef HAVE_FONTCONFIG_FONTCONFIG_H
/* Define if you have the <framebuffer.h> header file. */
#undef HAVE_FRAMEBUFFER_H
/* Define if you have the <ft2build.h> header file. */
#undef HAVE_FT2BUILD_H
@ -764,6 +770,9 @@
/* Define if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define if you have the <sys/keycodes.h> header file. */
#undef HAVE_SYS_KEYCODES_H
/* Define if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
@ -848,6 +857,9 @@
/* Define if you have the bz2 library (-lbz2). */
#undef HAVE_LIBBZ2
/* Define if you have the display library (-ldisplay). */
#undef HAVE_LIBDISPLAY
/* Define if you have the dl library (-ldl). */
#undef HAVE_LIBDL
@ -1173,6 +1185,9 @@
/* */
#undef GRDRV_GRX
/* */
#undef GRDRV_SORTIX
/* Have freetype */
#undef HAVE_FREETYPE

111
configure vendored
View File

@ -69,6 +69,8 @@ ac_help="$ac_help
--without-haiku compile without Haiku graphics driver"
ac_help="$ac_help
--without-grx compile without DOS GRX graphics driver"
ac_help="$ac_help
--without-sortix compile without Sortix display(1) graphics driver"
ac_help="$ac_help
--with-x use the X Window System"
ac_help="$ac_help
@ -118,7 +120,7 @@ libdir='${exec_prefix}/lib'
includedir='${prefix}/include'
oldincludedir='/usr/include'
infodir='${prefix}/info'
mandir='${prefix}/man'
mandir='${prefix}/share/man'
# Initialize some other variables.
subdirs=
@ -235,7 +237,7 @@ Directory and file names:
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--mandir=DIR man documentation in DIR [PREFIX/share/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
@ -8392,6 +8394,12 @@ if test "${with_grx+set}" = set; then
if test "$withval" = no; then disable_grx=yes; else disable_grx=no; fi
fi
# Check whether --with-sortix or --without-sortix was given.
if test "${with_sortix+set}" = set; then
withval="$with_sortix"
if test "$withval" = no; then disable_sortix=yes; else disable_sortix=no; fi
fi
drivers=""
@ -10416,6 +10424,105 @@ EOF
fi
fi
if test "$disable_sortix" != yes; then
for ac_hdr in display.h framebuffer.h sys/keycodes.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:10432: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 10437 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:10442: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
eval "ac_cv_header_$ac_safe=yes"
else
echo "$ac_err" >&5
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_header_$ac_safe=no"
fi
rm -f conftest*
fi
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
cat >> confdefs.h <<EOF
#define $ac_tr_hdr 1
EOF
else
echo "$ac_t""no" 1>&6
fi
done
echo $ac_n "checking for display_connect_default in -ldisplay""... $ac_c" 1>&6
echo "configure:10469: checking for display_connect_default in -ldisplay" >&5
ac_lib_var=`echo display'_'display_connect_default | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-ldisplay $LIBS"
cat > conftest.$ac_ext <<EOF
#line 10477 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char display_connect_default();
int main() {
display_connect_default()
; return 0; }
EOF
if { (eval echo configure:10488: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_lib=HAVE_LIB`echo display | sed -e 's/[^a-zA-Z0-9_]/_/g' \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
cat >> confdefs.h <<EOF
#define $ac_tr_lib 1
EOF
LIBS="-ldisplay $LIBS"
else
echo "$ac_t""no" 1>&6
fi
if test "$ac_cv_header_display_h" = yes &&
test "$ac_cv_header_framebuffer_h" = yes &&
test "$ac_cv_header_sys_keycodes_h" = yes &&
test "$ac_cv_lib_display_display_connect_default" = yes; then
cat >> confdefs.h <<\EOF
#define GRDRV_SORTIX 1
EOF
drivers="$drivers sortix"
fi
fi
# Check whether --with-freetype or --without-freetype was given.
if test "${with_freetype+set}" = set; then

View File

@ -1049,6 +1049,7 @@ AC_ARG_WITH(windows, [ --without-windows compile without Windows graphics
AC_ARG_WITH(atheos, [ --without-atheos compile without Atheos graphics driver],[if test "$withval" = no; then disable_atheos=yes; else disable_atheos=no; fi])
AC_ARG_WITH(haiku, [ --without-haiku compile without Haiku graphics driver],[if test "$withval" = no; then disable_haiku=yes; else disable_haiku=no; fi])
AC_ARG_WITH(grx, [ --without-grx compile without DOS GRX graphics driver],[if test "$withval" = no; then disable_grx=yes; else disable_grx=no; fi])
AC_ARG_WITH(sortix, [ --without-sortix compile without Sortix display(1) graphics driver],[if test "$withval" = no; then disable_sortix=yes; else disable_sortix=no; fi])
drivers=""
@ -1311,6 +1312,18 @@ if test "$disable_grx" != yes -a "$ac_cv_have_djgpp" = yes; then
fi
fi
if test "$disable_sortix" != yes; then
AC_CHECK_HEADERS(display.h framebuffer.h sys/keycodes.h)
AC_CHECK_LIB(display, display_connect_default)
if test "$ac_cv_header_display_h" = yes &&
test "$ac_cv_header_framebuffer_h" = yes &&
test "$ac_cv_header_sys_keycodes_h" = yes &&
test "$ac_cv_lib_display_display_connect_default" = yes; then
AC_DEFINE(GRDRV_SORTIX)
drivers="$drivers sortix"
fi
fi
AC_ARG_WITH(freetype, [ --without-freetype compile without freetype support],[if test "$withval" = no; then disable_freetype=yes; else disable_freetype=no; fi])
font_rendering=INTERNAL

View File

@ -307,7 +307,7 @@ int get_pasv_socket(struct connection *c, int cc, int *sock, unsigned char *port
}
#ifdef SUPPORT_IPV6
int get_pasv_socket_ipv6(struct connection *c, int cc, int *sock, unsigned char *result)
int get_pasv_socket_ipv6(struct connection *c, int cc, int *sock, unsigned char *result, size_t result_size)
{
int s;
int rs;
@ -335,7 +335,7 @@ int get_pasv_socket_ipv6(struct connection *c, int cc, int *sock, unsigned char
if (rs) goto e;
EINTRLOOP(rs, listen(s, 1));
if (rs) goto e;
sprintf(cast_char result, "|2|%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x|%d|",
snprintf(cast_char result, result_size, "|2|%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x|%d|",
sa.sin6_addr.s6_addr[0],
sa.sin6_addr.s6_addr[1],
sa.sin6_addr.s6_addr[2],
@ -672,7 +672,7 @@ static void try_connect(struct connection *c)
#if defined(__aarch64__) && defined(__ILP32__)
errno = EINPROGRESS; /* arm64 ilp32 bug */
#endif
EINTRLOOP(rs, connect(s, (struct sockaddr *)(void *)&sa, sizeof sa));
rs = connect(s, (struct sockaddr *)(void *)&sa, sizeof sa);
#ifdef SUPPORT_IPV6
} else if (addr->af == AF_INET6) {
struct sockaddr_in6 sa;
@ -686,14 +686,14 @@ static void try_connect(struct connection *c)
#if defined(__aarch64__) && defined(__ILP32__)
errno = EINPROGRESS; /* arm64 ilp32 bug */
#endif
EINTRLOOP(rs, connect(s, (struct sockaddr *)(void *)&sa, sizeof sa));
rs = connect(s, (struct sockaddr *)(void *)&sa, sizeof sa);
#endif
} else {
rs = -1;
errno = EINVAL;
}
if (rs) {
if (errno != EALREADY && errno != EINPROGRESS) {
if (errno != EALREADY && errno != EINPROGRESS && errno != EINTR) {
#ifdef BEOS
if (errno == EWOULDBLOCK) errno = ETIMEDOUT;
#endif

106
default.c
View File

@ -88,13 +88,13 @@ static void get_compiler_name(void)
if (v1 == 4 && v2 < 5) v1 = 3;
if (v1 == 4 && v2 == 5) v2 = 0;
if (!v3) sprintf(cast_char compiler_name, "Borland C %d.%d", v1, v2);
else sprintf(cast_char compiler_name, "Borland C %d.%d.%d", v1, v2, v3);
if (!v3) snprintf(cast_char compiler_name, sizeof(compiler_name), "Borland C %d.%d", v1, v2);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "Borland C %d.%d.%d", v1, v2, v3);
#elif defined(__clang__)
#if !defined(__clang_major__) || !defined(__clang_minor__)
sprintf(cast_char compiler_name, "LLVM/Clang");
snprintf(cast_char compiler_name, sizeof(compiler_name), "LLVM/Clang");
#else
int v1 = __clang_major__+0;
int v2 = __clang_minor__+0;
@ -103,8 +103,8 @@ static void get_compiler_name(void)
#else
int v3 = 0;
#endif
if (v3 > 0) sprintf(cast_char compiler_name, "LLVM/Clang %d.%d.%d", v1, v2, v3);
else sprintf(cast_char compiler_name, "LLVM/Clang %d.%d", v1, v2);
if (v3 > 0) snprintf(cast_char compiler_name, sizeof(compiler_name), "LLVM/Clang %d.%d.%d", v1, v2, v3);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "LLVM/Clang %d.%d", v1, v2);
#endif
#elif defined(__COMO_VERSION__)
@ -112,33 +112,33 @@ static void get_compiler_name(void)
int w = __COMO_VERSION__+0;
int v1 = w / 100;
int v2 = w % 100;
if (!(v2 % 10)) sprintf(cast_char compiler_name, "Comeau C %d.%d", v1, v2 / 10);
else sprintf(cast_char compiler_name, "Comeau C %d.%02d", v1, v2);
if (!(v2 % 10)) snprintf(cast_char compiler_name, sizeof(compiler_name), "Comeau C %d.%d", v1, v2 / 10);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "Comeau C %d.%02d", v1, v2);
#elif defined(__convexc__)
sprintf(cast_char compiler_name, "Convex C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Convex C");
#elif defined(_CRAYC)
#if !defined(_RELEASE) || !defined(_RELEASE_MINOR)
sprintf(cast_char compiler_name, "Cray C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Cray C");
#else
int v1 = _RELEASE+0;
int v2 = _RELEASE_MINOR+0;
sprintf(cast_char compiler_name, "Cray C %d.%d", v1, v2);
snprintf(cast_char compiler_name, sizeof(compiler_name), "Cray C %d.%d", v1, v2);
#endif
#elif defined(__DCC__)
#ifndef __VERSION_NUMBER__
sprintf(cast_char compiler_name, "Diab C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Diab C");
#else
int w = __VERSION_NUMBER__+0;
int v1 = w / 1000;
int v2 = w / 100 % 10;
int v3 = w % 100;
sprintf(cast_char compiler_name, "Diab C %d.%d.%02d", v1, v2, v3);
snprintf(cast_char compiler_name, sizeof(compiler_name), "Diab C %d.%d.%02d", v1, v2, v3);
#endif
#elif defined(__DMC__)
@ -147,8 +147,8 @@ static void get_compiler_name(void)
int v1 = w / 0x100;
int v2 = w / 0x10 % 0x10;
int v3 = w % 0x10;
if (!v3) sprintf(cast_char compiler_name, "Digital Mars C %d.%d", v1, v2);
else sprintf(cast_char compiler_name, "Digital Mars C %d.%d.%d", v1, v2, v3);
if (!v3) snprintf(cast_char compiler_name, sizeof(compiler_name), "Digital Mars C %d.%d", v1, v2);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "Digital Mars C %d.%d.%d", v1, v2, v3);
#elif defined(__DECC_VER)
@ -156,23 +156,23 @@ static void get_compiler_name(void)
int v1 = w / 10000000;
int v2 = w / 100000 % 100;
int v3 = w % 10000;
sprintf(cast_char compiler_name, "DEC C %d.%d-%03d", v1, v2, v3);
snprintf(cast_char compiler_name, sizeof(compiler_name), "DEC C %d.%d-%03d", v1, v2, v3);
#elif defined(__ghs__)
#ifndef __GHS_VERSION_NUMBER__
sprintf(cast_char compiler_name, "Green Hill C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Green Hill C");
#else
int w = __GHS_VERSION_NUMBER__+0;
int v1 = w / 100;
int v2 = w / 10 % 10;
int v3 = w % 10;
sprintf(cast_char compiler_name, "Green Hill C %d.%d.%d", v1, v2, v3);
snprintf(cast_char compiler_name, sizeof(compiler_name), "Green Hill C %d.%d.%d", v1, v2, v3);
#endif
#elif defined(__HIGHC__)
sprintf(cast_char compiler_name, "MetaWare High C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "MetaWare High C");
#elif defined(__HP_cc)
@ -180,15 +180,15 @@ static void get_compiler_name(void)
int v1 = w / 10000;
int v2 = w / 100 % 100;
int v3 = w % 100;
if (w <= 1) sprintf(cast_char compiler_name, "HP CC");
else sprintf(cast_char compiler_name, "HP CC %d.%02d.%02d", v1, v2, v3);
if (w <= 1) snprintf(cast_char compiler_name, sizeof(compiler_name), "HP CC");
else snprintf(cast_char compiler_name, sizeof(compiler_name), "HP CC %d.%02d.%02d", v1, v2, v3);
#elif defined(__xlc__)
int w = __xlc__+0;
int v1 = w / 0x100;
int v2 = w % 0x100;
sprintf(cast_char compiler_name, "IBM XL C %X.%X", v1, v2);
snprintf(cast_char compiler_name, sizeof(compiler_name), "IBM XL C %X.%X", v1, v2);
#elif defined(__IBMC__) && defined(__COMPILER_VER__)
@ -198,23 +198,23 @@ static void get_compiler_name(void)
int v2 = w / 0x10000 % 0x100;
int v3 = w % 0x10000;
unsigned char *os = !v0 ? "S/370" : v0 == 1 ? "OS/390" : v0 == 4 ? "z/OS" : "";
sprintf(cast_char compiler_name, "IBM%s%s XL C %X.%0X.%X", *os ? " " : "", os, v1, v2, v3);
snprintf(cast_char compiler_name, sizeof(compiler_name), "IBM%s%s XL C %X.%0X.%X", *os ? " " : "", os, v1, v2, v3);
#elif defined(__ICC)
int w = __ICC+0;
int v1 = w / 100;
int v2 = w % 100;
if (!(v2 % 10)) sprintf(cast_char compiler_name, "Intel C %d.%d", v1, v2 / 10);
else sprintf(cast_char compiler_name, "Intel C %d.%02d", v1, v2);
if (!(v2 % 10)) snprintf(cast_char compiler_name, sizeof(compiler_name), "Intel C %d.%d", v1, v2 / 10);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "Intel C %d.%02d", v1, v2);
#elif defined(__LCC__)
sprintf(cast_char compiler_name, "LCC");
snprintf(cast_char compiler_name, sizeof(compiler_name), "LCC");
#elif defined(__NDPC__)
sprintf(cast_char compiler_name, "Microway NDP C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Microway NDP C");
#elif defined(_MSC_VER)
@ -227,8 +227,8 @@ static void get_compiler_name(void)
if (v1 == 2) v1 = 1;
visual = cast_uchar "Visual ";
}
if (!(v2 % 10)) sprintf(cast_char compiler_name, "Microsoft %sC %d.%d", visual, v1, v2 / 10);
else sprintf(cast_char compiler_name, "Microsoft %sC %d.%02d", visual, v1, v2);
if (!(v2 % 10)) snprintf(cast_char compiler_name, sizeof(compiler_name), "Microsoft %sC %d.%d", visual, v1, v2 / 10);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "Microsoft %sC %d.%02d", visual, v1, v2);
#elif defined(__MWERKS__)
@ -236,12 +236,12 @@ static void get_compiler_name(void)
int v1 = w / 0x1000;
int v2 = w / 0x100 % 0x10;
int v3 = w % 0x100;
if (w <= 1) sprintf(cast_char compiler_name, "Metrowerks CodeWarrior");
sprintf(cast_char compiler_name, "Metrowerks CodeWarrior %x.%x.%x", v1, v2, v3);
if (w <= 1) snprintf(cast_char compiler_name, sizeof(compiler_name), "Metrowerks CodeWarrior");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Metrowerks CodeWarrior %x.%x.%x", v1, v2, v3);
#elif defined(__NWCC__)
sprintf(cast_char compiler_name, "NWCC");
snprintf(cast_char compiler_name, sizeof(compiler_name), "NWCC");
#elif defined(__OPEN64__)
@ -268,12 +268,12 @@ static void get_compiler_name(void)
#else
int v3 = 0;
#endif
sprintf(cast_char compiler_name, "PCC %d.%d.%d", v1, v2, v3);
snprintf(cast_char compiler_name, sizeof(compiler_name), "PCC %d.%d.%d", v1, v2, v3);
#elif defined(__PGI) || defined(__PGIC__)
#if !defined(__PGIC__) || !defined(__PGIC_MINOR__)
sprintf(cast_char compiler_name, "The Portland Group C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "The Portland Group C");
#else
int v1 = __PGIC__+0;
int v2 = __PGIC_MINOR__+0;
@ -282,8 +282,8 @@ static void get_compiler_name(void)
#else
int v3 = 0;
#endif
if (v3 > 0) sprintf(cast_char compiler_name, "The Portland Group C %d.%d.%d", v1, v2, v3);
else sprintf(cast_char compiler_name, "The Portland Group C %d.%d", v1, v2);
if (v3 > 0) snprintf(cast_char compiler_name, sizeof(compiler_name), "The Portland Group C %d.%d.%d", v1, v2, v3);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "The Portland Group C %d.%d", v1, v2);
#endif
#elif defined(__SASC__)
@ -291,7 +291,7 @@ static void get_compiler_name(void)
int w = __SASC__+0;
int v1 = w / 100;
int v2 = w % 100;
sprintf(cast_char compiler_name, "SAS C %d.%02d", v1, v2);
snprintf(cast_char compiler_name, sizeof(compiler_name), "SAS C %d.%02d", v1, v2);
#elif (defined(__sgi) && defined(_COMPILER_VERSION)) || defined(_SGI_COMPILER_VERSION)
@ -303,7 +303,7 @@ static void get_compiler_name(void)
int v1 = w / 100;
int v2 = w / 10 % 10;
int v3 = w % 10;
sprintf(cast_char compiler_name, "MIPSpro %d.%d.%d", v1, v2, v3);
snprintf(cast_char compiler_name, sizeof(compiler_name), "MIPSpro %d.%d.%d", v1, v2, v3);
#elif defined(__SUNPRO_C)
@ -313,8 +313,8 @@ static void get_compiler_name(void)
int v1 = w / div;
int v2 = w % div / 0x10;
int v3 = w % 0x10;
if (!v3) sprintf(cast_char compiler_name, "Sun C %X.%0*X", v1, v2_digits, v2);
else sprintf(cast_char compiler_name, "Sun C %X.%0*X.%X", v1, v2_digits, v2, v3);
if (!v3) snprintf(cast_char compiler_name, sizeof(compiler_name), "Sun C %X.%0*X", v1, v2_digits, v2);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "Sun C %X.%0*X.%X", v1, v2_digits, v2, v3);
#elif defined(__SYSC__) && defined(__SYSC_VER__)
@ -322,37 +322,37 @@ static void get_compiler_name(void)
int v1 = w / 10000;
int v2 = w / 100 % 100;
int v3 = w % 100;
sprintf(cast_char compiler_name, "Dignus Systems C %d.%02d.%02d", v1, v2, v3);
snprintf(cast_char compiler_name, sizeof(compiler_name), "Dignus Systems C %d.%02d.%02d", v1, v2, v3);
#elif defined(__TenDRA__)
sprintf(cast_char compiler_name, "TenDRA C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "TenDRA C");
#elif defined(__TINYC__)
sprintf(cast_char compiler_name, "Tiny C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Tiny C");
#elif defined(_UCC)
#if !defined(_MAJOR_REV) || !defined(_MINOR_REV)
sprintf(cast_char compiler_name, "Ultimate C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Ultimate C");
#else
int v1 = _MAJOR_REV+0;
int v2 = _MAJOR_REV+0;
sprintf(cast_char compiler_name, "Ultimate C %d.%d", v1, v2);
snprintf(cast_char compiler_name, sizeof(compiler_name), "Ultimate C %d.%d", v1, v2);
#endif
#elif defined(__USLC__)
sprintf(cast_char compiler_name, "USL C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "USL C");
#elif defined(__VAXC)
sprintf(cast_char compiler_name, "VAX C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "VAX C");
#elif defined(__VOSC__)
sprintf(cast_char compiler_name, "Stratus VOS C");
snprintf(cast_char compiler_name, sizeof(compiler_name), "Stratus VOS C");
#elif defined(__WATCOMC__)
@ -364,8 +364,8 @@ static void get_compiler_name(void)
v1 -= 11;
op = cast_uchar "Open";
}
if (!(v2 % 10)) sprintf(cast_char compiler_name, "%sWatcom C %d.%d", op, v1, v2 / 10);
else sprintf(cast_char compiler_name, "%sWatcom C %d.%02d", op, v1, v2);
if (!(v2 % 10)) snprintf(cast_char compiler_name, sizeof(compiler_name), "%sWatcom C %d.%d", op, v1, v2 / 10);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "%sWatcom C %d.%02d", op, v1, v2);
#elif defined(__GNUC__)
@ -385,10 +385,10 @@ static void get_compiler_name(void)
#else
unsigned char *prefix = cast_uchar "";
#endif
if (v1 == 2 && (v2 >= 90 && v2 <= 91)) sprintf(cast_char compiler_name, "%sEGCS 1.%d", prefix, v2 - 90);
else if (v3 > 0 && v2 >= 0) sprintf(cast_char compiler_name, "%sGNU C %d.%d.%d", prefix, v1, v2, v3);
else if (v2 >= 0) sprintf(cast_char compiler_name, "%sGNU C %d.%d", prefix, v1, v2);
else sprintf(cast_char compiler_name, "%sGNU C %d", prefix, v1);
if (v1 == 2 && (v2 >= 90 && v2 <= 91)) snprintf(cast_char compiler_name, sizeof(compiler_name), "%sEGCS 1.%d", prefix, v2 - 90);
else if (v3 > 0 && v2 >= 0) snprintf(cast_char compiler_name, sizeof(compiler_name), "%sGNU C %d.%d.%d", prefix, v1, v2, v3);
else if (v2 >= 0) snprintf(cast_char compiler_name, sizeof(compiler_name), "%sGNU C %d.%d", prefix, v1, v2);
else snprintf(cast_char compiler_name, sizeof(compiler_name), "%sGNU C %d", prefix, v1);
#else

2
dns.c
View File

@ -773,7 +773,7 @@ int ipv6_full_access(void)
sin6.sin6_family = AF_INET6;
sin6.sin6_port = htons(1024);
memcpy(&sin6.sin6_addr.s6_addr, "\052\001\004\060\000\015\000\000\002\314\236\377\376\044\176\032", 16);
EINTRLOOP(c, connect(h, (struct sockaddr *)(void *)&sin6, sizeof sin6));
c = blocking_connect(h, (struct sockaddr *)(void *)&sin6, sizeof sin6);
EINTRLOOP(rs, close(h));
if (!c) return 1;
#endif

View File

@ -40,6 +40,10 @@ extern struct graphics_driver grx_driver;
#ifdef GRDRV_SDL
extern struct graphics_driver sdl_driver;
#endif
#ifdef GRDRV_SORTIX
extern struct graphics_driver sortix_driver;
#endif
/*
* On SPAD you must test first svgalib and then X (because X test is slow).
@ -82,6 +86,9 @@ static struct graphics_driver *graphics_drivers[] = {
#endif
#ifdef GRDRV_SDL
&sdl_driver,
#endif
#ifdef GRDRV_SORTIX
&sortix_driver,
#endif
NULL
};

View File

@ -412,14 +412,14 @@ void int_error(const char *m, ...)
#else
va_list l;
sprintf(cast_char errbuf, "Internal error at %s:%d\r\n%s", errfile, errline, m);
snprintf(cast_char errbuf, sizeof(errbuf), "Internal error at %s:%d\r\n%s", errfile, errline, m);
va_start(l, m);
os_report_error_va("Internal error", cast_const_char errbuf, l);
va_end(l);
fatal_tty_exit();
sprintf(cast_char errbuf, "\n"ANSI_SET_BOLD"INTERNAL ERROR"ANSI_CLEAR_BOLD" at %s:%d: %s", errfile, errline, m);
snprintf(cast_char errbuf, sizeof(errbuf), "\n"ANSI_SET_BOLD"INTERNAL ERROR"ANSI_CLEAR_BOLD" at %s:%d: %s", errfile, errline, m);
va_start(l, m);
er(1, cast_char errbuf, l);
va_end(l);
@ -433,7 +433,7 @@ void debug_msg(const char *m, ...)
{
va_list l;
va_start(l, m);
sprintf(cast_char errbuf, "\nDEBUG MESSAGE at %s:%d: %s", errfile, errline, m);
snprintf(cast_char errbuf, sizeof(errbuf), "\nDEBUG MESSAGE at %s:%d: %s", errfile, errline, m);
er(0, cast_char errbuf, l);
va_end(l);
}

10
file.c
View File

@ -104,7 +104,7 @@ static void stat_links(unsigned char **p, int *l, struct stat *stp)
unsigned char lnk[64];
if (!stp) add_to_str(p, l, cast_uchar " ");
else {
sprintf(cast_char lnk, "%3ld ", (unsigned long)stp->st_nlink);
snprintf(cast_char lnk, sizeof(lnk), "%3ld ", (unsigned long)stp->st_nlink);
add_to_str(p, l, lnk);
}
#endif
@ -136,13 +136,13 @@ static void stat_user(unsigned char **p, int *l, struct stat *stp, int g)
if (g && id == last_gid && last_gid != -1) goto a;
if (!g) {
ENULLLOOP(pwd, getpwuid(id));
if (!pwd || !pwd->pw_name) sprintf(cast_char pp, "%d", id);
else sprintf(cast_char pp, "%.8s", pwd->pw_name);
if (!pwd || !pwd->pw_name) snprintf(cast_char pp, sizeof(last_user), "%d", id);
else snprintf(cast_char pp, sizeof(last_user), "%.8s", pwd->pw_name);
last_uid = id;
} else {
ENULLLOOP(grp, getgrgid(id));
if (!grp || !grp->gr_name) sprintf(cast_char pp, "%d", id);
else sprintf(cast_char pp, "%.8s", grp->gr_name);
if (!grp || !grp->gr_name) snprintf(cast_char pp, sizeof(last_group), "%d", id);
else snprintf(cast_char pp, sizeof(last_group), "%.8s", grp->gr_name);
last_gid = id;
}
a:

6
ftp.c
View File

@ -250,7 +250,7 @@ static struct ftp_connection_info *add_file_cmd_to_str(struct connection *c, int
int ps;
#ifdef SUPPORT_IPV6
if (is_ipv6(c->sock1)) {
ps = get_pasv_socket_ipv6(c, c->sock1, &c->sock2, port_string);
ps = get_pasv_socket_ipv6(c, c->sock1, &c->sock2, port_string, sizeof(port_string));
if (ps) {
mem_free(d);
mem_free(s);
@ -267,9 +267,9 @@ static struct ftp_connection_info *add_file_cmd_to_str(struct connection *c, int
return NULL;
}
if (inf->eprt_epsv)
sprintf(cast_char port_string, "|1|%d.%d.%d.%d|%d|", pc[0], pc[1], pc[2], pc[3], (pc[4] << 8) | pc[5]);
snprintf(cast_char port_string, sizeof(port_string), "|1|%d.%d.%d.%d|%d|", pc[0], pc[1], pc[2], pc[3], (pc[4] << 8) | pc[5]);
else
sprintf(cast_char port_string, "%d,%d,%d,%d,%d,%d", pc[0], pc[1], pc[2], pc[3], pc[4], pc[5]);
snprintf(cast_char port_string, sizeof(port_string), "%d,%d,%d,%d,%d,%d", pc[0], pc[1], pc[2], pc[3], pc[4], pc[5]);
}
if (strlen(cast_const_char port_string) >= sizeof(port_string))
internal_error("buffer overflow in get_pasv_socket_ipv6: %d > %d", (int)strlen(cast_const_char port_string), (int)sizeof(port_string));

2
html.c
View File

@ -1633,7 +1633,7 @@ static void html_li(unsigned char *a)
unsigned char *x;
for (x = n; *x; x++) *x = upcase(*x);
}
} else sprintf(cast_char n, "%d", par_format.list_number);
} else snprintf(cast_char n, sizeof(n), "%d", par_format.list_number);
put_chrs(n, (int)strlen(cast_const_char n));
put_chrs(cast_uchar ".&nbsp;", 7);
if (!F) par_format.leftmargin += (int)strlen(cast_const_char n) + c + 2;

2
http.c
View File

@ -353,7 +353,7 @@ static void add_url_to_str(unsigned char **str, int *l, unsigned char *url)
for (sp = url; *sp && *sp != POST_CHAR; sp++) {
if (*sp <= ' ' || *sp >= 127) {
unsigned char esc[4];
sprintf(cast_char esc, "%%%02X", (int)*sp);
snprintf(cast_char esc, 4, "%%%02X", (int)*sp);
add_to_str(str, l, esc);
} else {
add_chr_to_str(str, l, *sp);

View File

@ -1140,6 +1140,7 @@ extern int terminate_loop;
int can_write(int fd);
int can_read(int fd);
int can_read_timeout(int fd, int sec);
int blocking_connect(int fd, struct sockaddr *addr, socklen_t addrlen);
int close_std_handle(int);
void restore_std_handle(int, int);
unsigned long select_info(int);
@ -1581,7 +1582,7 @@ void continue_connection(struct connection *, int *, void (*)(struct connection
int is_ipv6(int);
int get_pasv_socket(struct connection *, int, int *, unsigned char *);
#ifdef SUPPORT_IPV6
int get_pasv_socket_ipv6(struct connection *, int, int *, unsigned char *);
int get_pasv_socket_ipv6(struct connection *, int, int *, unsigned char *, size_t);
#endif
void write_to_socket(struct connection *, int, unsigned char *, int, void (*)(struct connection *));
struct read_buffer *alloc_read_buffer(struct connection *c);

4
menu.c
View File

@ -3872,8 +3872,8 @@ static void dlg_resize_terminal(struct terminal *term, void *xxx, void *ses_)
struct dialog *d;
unsigned x = (unsigned)term->x > 999 ? 999 : term->x;
unsigned y = (unsigned)term->y > 999 ? 999 : term->y;
sprintf(cast_char x_str, "%u", x);
sprintf(cast_char y_str, "%u", y);
snprintf(cast_char x_str, sizeof(x_str), "%u", x);
snprintf(cast_char y_str, sizeof(y_str), "%u", y);
d = mem_calloc(sizeof(struct dialog) + 4 * sizeof(struct dialog_item));
d->title = TEXT_(T_RESIZE_TERMINAL);
d->fn = group_fn;

View File

@ -3434,6 +3434,14 @@ int os_default_charset(void)
return 0;
}
// PATCH: Always use UTF-8 instead of language-specific terminal charsets
#elif defined(__sortix__)
int os_default_charset(void)
{
return utf8_table;
}
#elif !defined(DOS)
int os_default_charset(void)

View File

@ -125,6 +125,22 @@ int can_read(int fd)
}
// PATCH: Handle connect not being restartable
int blocking_connect(int fd, struct sockaddr *addr, socklen_t addrlen)
{
int connect_error;
socklen_t len = sizeof(int);
if (!connect(fd, addr, addrlen)) return 0;
if (errno != EINTR) return -1;
can_do_io(fd, 1, -1); // Wait until connected/failed
getsockopt(fd, SOL_SOCKET, SO_ERROR, &connect_error, &len);
errno = connect_error;
return !connect_error ? 0 : -1;
}
int close_std_handle(int std)
{
#ifndef DOS

View File

@ -192,10 +192,10 @@ static void add_xnum_to_str(unsigned char **s, int *l, off_t n)
static void add_time_to_str(unsigned char **s, int *l, uttime t)
{
unsigned char q[64];
if (t >= 86400) sprintf(cast_char q, "%lud ", (unsigned long)(t / 86400)), add_to_str(s, l, q);
if (t >= 3600) t %= 86400, sprintf(cast_char q, "%d:%02d", (int)(t / 3600), (int)(t / 60 % 60)), add_to_str(s, l, q);
else sprintf(cast_char q, "%d", (int)(t / 60)), add_to_str(s, l, q);
sprintf(cast_char q, ":%02d", (int)(t % 60)), add_to_str(s, l, q);
if (t >= 86400) snprintf(cast_char q, sizeof(q), "%lud ", (unsigned long)(t / 86400)), add_to_str(s, l, q);
if (t >= 3600) t %= 86400, snprintf(cast_char q, sizeof(q), "%d:%02d", (int)(t / 3600), (int)(t / 60 % 60)), add_to_str(s, l, q);
else snprintf(cast_char q, sizeof(q), "%d", (int)(t / 60)), add_to_str(s, l, q);
snprintf(cast_char q, sizeof(q), ":%02d", (int)(t % 60)), add_to_str(s, l, q);
}
static unsigned char *get_stat_msg(struct status *stat, struct terminal *term)

9
sortix.c Normal file
View File

@ -0,0 +1,9 @@
#include "cfg.h"
#ifdef GRDRV_SORTIX
#include "links.h"
struct graphics_driver sortix_driver;
#endif /* GRDRV_SORTIX */

6
tixbuildinfo Normal file
View File

@ -0,0 +1,6 @@
tix.version=1
tix.class=srctix
pkg.name=links
pkg.build-libraries=libssl libz libevent? xz?
pkg.build-system=configure
pkg.location-independent=true

6
url.c
View File

@ -336,7 +336,7 @@ static unsigned char *translate_hashbang(unsigned char *up)
unsigned char c = *dp;
if (c <= 0x20 || c == 0x23 || c == 0x25 || c == 0x26 || c == 0x2b || c >= 0x7f) {
unsigned char h[4];
sprintf(cast_char h, "%%%02X", c);
snprintf(cast_char h, 4, "%%%02X", c);
add_to_str(&r, &rl, h);
} else {
add_chr_to_str(&r, &rl, c);
@ -501,7 +501,7 @@ static void insert_wd(unsigned char **up, unsigned char *cwd)
unsigned char c = *cw;
if (c < ' ' || c == '%' || c >= 127) {
unsigned char h[4];
sprintf(cast_char h, "%%%02X", (unsigned)c & 0xff);
snprintf(cast_char h, 4, "%%%02X", (unsigned)c & 0xff);
add_to_str(&url, &url_l, h);
} else {
add_chr_to_str(&url, &url_l, c);
@ -749,7 +749,7 @@ void add_conv_str(unsigned char **s, int *l, unsigned char *b, int ll, int encod
if (!chr) continue;
if (special_char(chr) && encode_special == 1) {
unsigned char h[4];
sprintf(cast_char h, "%%%02X", (unsigned)chr & 0xff);
snprintf(cast_char h, 4, "%%%02X", (unsigned)chr & 0xff);
add_to_str(s, l, h);
continue;
}

4
view.c
View File

@ -2035,7 +2035,7 @@ static void encode_string(unsigned char *name, unsigned char **data, int *len)
else if (safe_char(*name)) add_chr_to_str(data, len, *name);
else {
unsigned char n[4];
sprintf(cast_char n, "%%%02X", *name);
snprintf(cast_char n, 4, "%%%02X", *name);
add_to_str(data, len, n);
}
}
@ -2270,7 +2270,7 @@ unsigned char *get_form_url(struct session *ses, struct f_data_c *f, struct form
}
for (i = 0; i < len; i++) {
unsigned char p[3];
sprintf(cast_char p, "%02x", (int)data[i]);
snprintf(cast_char p, 3, "%02x", (int)data[i]);
add_to_str(&go, &l, p);
}
}