diff -u -r --new-file mc-4.6.0.orig/configure mc-4.6.0/configure --- mc-4.6.0.orig/configure 2003-02-05 10:09:04.000000000 -0800 +++ mc-4.6.0/configure 2004-05-27 12:49:41.000000000 -0700 @@ -5282,7 +5282,7 @@ ALL_LINGUAS="az be bg ca cs da de el es eu fi fr hu it ja ko lv \ -nl no pl pt pt_BR ro ru sk sl sv uk ta tr wa zh_CN zh_TW" +nl no pl pt pt_BR ro ru sk sl sv uk tr wa zh_CN zh_TW" MKINSTALLDIRS= diff -u -r --new-file mc-4.6.0.orig/doc/es/mc.1.in mc-4.6.0/doc/es/mc.1.in --- mc-4.6.0.orig/doc/es/mc.1.in 2003-02-05 07:54:31.000000000 -0800 +++ mc-4.6.0/doc/es/mc.1.in 2004-05-27 12:49:31.000000000 -0700 @@ -1361,8 +1361,10 @@ od -c %f B Edita un informe de errores y lo enva al superusuario - vi /tmp/mail.$$ - mail -s "Error Midnight Commander" root < /tmp/mail.$$ + I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1 + vi $I + mail -s "Error Midnight Commander" root < $I + rm -f $I M Lee al correo emacs -f rmail diff -u -r --new-file mc-4.6.0.orig/doc/hu/mc.1.in mc-4.6.0/doc/hu/mc.1.in --- mc-4.6.0.orig/doc/hu/mc.1.in 2003-01-16 02:30:55.000000000 -0800 +++ mc-4.6.0/doc/hu/mc.1.in 2004-05-27 12:49:31.000000000 -0700 @@ -1381,8 +1381,10 @@ od -c %f B A hiba lers szerkesztse s elkldse a root-nak - vi /tmp/mail.$$ - mail -s "Midnight Commander bug" root < /tmp/mail.$$ + I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1 + vi $I + mail -s "Midnight Commander bug" root < $I + rm -f $I M Levl olvass emacs -f rmail diff -u -r --new-file mc-4.6.0.orig/doc/it/mc.1.in mc-4.6.0/doc/it/mc.1.in --- mc-4.6.0.orig/doc/it/mc.1.in 2003-01-19 09:11:06.000000000 -0800 +++ mc-4.6.0/doc/it/mc.1.in 2004-05-27 12:49:31.000000000 -0700 @@ -1379,8 +1379,10 @@ od -c %f B Modifica un rapporto bachi e lo spedisce a root - vi /tmp/mail.$$ - mail -s "Midnight Commander bug" root < /tmp/mail.$$ + I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1 + vi $I + mail -s "Midnight Commander bug" root < $I + rm -f $I M Legge la posta emacs -f rmail diff -u -r --new-file mc-4.6.0.orig/doc/mc.1.in mc-4.6.0/doc/mc.1.in --- mc-4.6.0.orig/doc/mc.1.in 2003-02-05 07:54:31.000000000 -0800 +++ mc-4.6.0/doc/mc.1.in 2004-05-27 12:49:31.000000000 -0700 @@ -1385,8 +1385,10 @@ od -c %f B Edit a bug report and send it to root - vi /tmp/mail.$$ - mail -s "Midnight Commander bug" root < /tmp/mail.$$ + I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1 + vi $I + mail -s "Midnight Commander bug" root < $I + rm -f $I M Read mail emacs -f rmail diff -u -r --new-file mc-4.6.0.orig/doc/ru/mc.1.in mc-4.6.0/doc/ru/mc.1.in --- mc-4.6.0.orig/doc/ru/mc.1.in 2003-02-03 13:59:14.000000000 -0800 +++ mc-4.6.0/doc/ru/mc.1.in 2004-05-27 12:49:31.000000000 -0700 @@ -1557,8 +1557,10 @@ od -c %f B Edit a bug report and send it to root - vi /tmp/mail.$$ - mail -s "Midnight Commander bug" root < /tmp/mail.$$ + I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1 + vi $I + mail -s "Midnight Commander bug" root < $I + rm -f $I M Read mail emacs -f rmail diff -u -r --new-file mc-4.6.0.orig/edit/editcmd.c mc-4.6.0/edit/editcmd.c --- mc-4.6.0.orig/edit/editcmd.c 2002-12-19 05:01:34.000000000 -0800 +++ mc-4.6.0/edit/editcmd.c 2004-05-27 12:49:30.000000000 -0700 @@ -1563,7 +1563,7 @@ static int sprintf_p (char *str, const char *fmt,...) { va_list ap; - int n; + size_t n; char *q, *p, *s = str; char q1[32]; char *p1; @@ -1573,7 +1573,7 @@ while ((p = strchr (p, '%'))) { n = p - q; - strncpy (s, q, n); /* copy stuff between format specifiers */ + memcpy (s, q, n); /* copy stuff between format specifiers */ s += n; *s = 0; q = p; @@ -2711,7 +2711,7 @@ int word_len = 0, i, num_compl = 0, max_len; long word_start = 0; char *bufpos; - char match_expr[MAX_REPL_LEN]; + char *match_expr; struct selection compl[MAX_WORD_COMPLETIONS]; /* completions */ /* don't want to disturb another search */ @@ -2728,9 +2728,7 @@ /* prepare match expression */ bufpos = &edit->buffers1[word_start >> S_EDIT_BUF_SIZE] [word_start & M_EDIT_BUF_SIZE]; - strncpy (match_expr, bufpos, word_len); - match_expr[word_len] = '\0'; - strcat (match_expr, "[a-zA-Z_0-9]+"); + match_expr = g_strdup_printf ("%.*s[a-zA-Z_0-9]+", word_len, bufpos); /* init search: backward, regexp, whole word, case sensitive */ edit_set_search_parameters (0, 1, 1, 1, 1); @@ -2762,6 +2760,8 @@ } /* release memory before return */ + g_free (match_expr); + for (i = 0; i < num_compl; i++) g_free (compl[i].text); diff -u -r --new-file mc-4.6.0.orig/edit/syntax.c mc-4.6.0/edit/syntax.c --- mc-4.6.0.orig/edit/syntax.c 2002-12-15 10:55:53.000000000 -0800 +++ mc-4.6.0/edit/syntax.c 2004-05-27 12:49:30.000000000 -0700 @@ -99,7 +99,8 @@ for (p = (unsigned char *) text, q = p + strlen ((char *) p); p < q; p++, i++) { switch (*p) { case '\001': - p++; + if (++p > q) + return -1; for (;;) { c = edit_get_byte (edit, i); if (!*p) @@ -114,7 +115,8 @@ } break; case '\002': - p++; + if (++p > q) + return -1; j = 0; for (;;) { c = edit_get_byte (edit, i); @@ -150,12 +152,13 @@ } break; case '\003': - p++; + if (++p > q) + return -1; c = -1; for (;; i++) { d = c; c = edit_get_byte (edit, i); - for (j = 0; p[j] != '\003'; j++) + for (j = 0; p[j] != '\003' && p[j]; j++) if (c == p[j]) goto found_char2; break; @@ -163,20 +166,23 @@ j = c; /* dummy command */ } i--; - while (*p != '\003') + while (*p != '\003' && p <= q) p++; + if (p > q) + return -1; if (p[1] == d) i--; break; case '\004': - p++; + if (++p > q) + return -1; c = edit_get_byte (edit, i); - for (; *p != '\004'; p++) + for (; *p != '\004' && *p; p++) if (c == *p) goto found_char3; return -1; found_char3: - for (; *p != '\004'; p++); + for (; *p != '\004' && *p; p++); break; default: if (*p != edit_get_byte (edit, i)) @@ -534,14 +540,14 @@ if (!*fg) fg = 0; if (fg) { - strcpy (f, fg); + g_strlcpy (f, fg, sizeof (f)); p = strchr (f, '/'); if (p) *p = '\0'; fg = f; } if (bg) { - strcpy (b, bg); + g_strlcpy (b, bg, sizeof (b)); p = strchr (b, '/'); if (p) *p = '\0'; @@ -637,13 +643,13 @@ check_a; if (!strcmp (*a, "left")) { a++; - strcpy (whole_left, *a); + g_strlcpy (whole_left, *a, sizeof (whole_left)); } else if (!strcmp (*a, "right")) { a++; - strcpy (whole_right, *a); + g_strlcpy (whole_right, *a, sizeof (whole_right)); } else { - strcpy (whole_left, *a); - strcpy (whole_right, *a); + g_strlcpy (whole_left, *a, sizeof (whole_left)); + g_strlcpy (whole_right, *a, sizeof (whole_right)); } a++; check_not_a; @@ -705,8 +711,8 @@ bg = *a; if (*a) a++; - strcpy (last_fg, fg ? fg : ""); - strcpy (last_bg, bg ? bg : ""); + g_strlcpy (last_fg, fg ? fg : "", sizeof (last_fg)); + g_strlcpy (last_bg, bg ? bg : "", sizeof (last_bg)); c->keyword[0]->color = this_try_alloc_color_pair (fg, bg); c->keyword[0]->keyword = g_strdup (" "); check_not_a; diff -u -r --new-file mc-4.6.0.orig/lib/cedit.menu mc-4.6.0/lib/cedit.menu --- mc-4.6.0.orig/lib/cedit.menu 2002-08-24 10:39:08.000000000 -0700 +++ mc-4.6.0/lib/cedit.menu 2004-05-27 12:49:31.000000000 -0700 @@ -449,7 +449,7 @@ m view `man' MAN=%{Enter name of man:} - TMPFILE=/tmp/mcview.$MAN.$$ + TMPFILE=`mktemp ${MC_TMPDIR:-/tmp}/mcview.$MAN.$$` || exit 1 man -Pcat $MAN >$TMPFILE mcview $TMPFILE rm -f $TMPFILE diff -u -r --new-file mc-4.6.0.orig/lib/mc.ext.in mc-4.6.0/lib/mc.ext.in --- mc-4.6.0.orig/lib/mc.ext.in 2003-01-30 07:48:33.000000000 -0800 +++ mc-4.6.0/lib/mc.ext.in 2004-05-27 12:47:09.000000000 -0700 @@ -221,7 +221,7 @@ View=sxpm %f include/image - Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (ee %f &); fi + Open=if [ "$DISPLAY" = "" ]; then zgv %f; else (display %f &); fi View=%view{ascii} identify %f #View=%view{ascii} asciiview %f @@ -290,7 +290,7 @@ # PDF type/^PDF - Open=(xpdf %f &) + Open=(xpdf %f >/dev/null&) #Open=(acroread %f &) #Open=(ghostview %f &) View=%view{ascii} pdftotext %f - diff -u -r --new-file mc-4.6.0.orig/lib/mc.menu mc-4.6.0/lib/mc.menu --- mc-4.6.0.orig/lib/mc.menu 2002-12-07 17:12:19.000000000 -0800 +++ mc-4.6.0/lib/mc.menu 2004-05-27 12:49:31.000000000 -0700 @@ -14,9 +14,10 @@ 0 Edit a bug report and send it to root - ${EDITOR-vi} /tmp/mail.$$ - test -r /tmp/mail.$$ && mail root < /tmp/mail.$$ - rm -f /tmp/mail.$$ + I=`mktemp ${MC_TMPDIR:-/tmp}/mail.XXXXXX` || exit 1 + ${EDITOR-vi} $I + test -r $I && mail root < $I + rm -f $I =+ f \.1$ | f \.3$ | f \.4$ | f \.5$ | f \.6$ | f \.7$ | f \.8$ | f \.man$ & t r 1 Display the file with roff -man @@ -112,8 +113,9 @@ CHECK=`awk '{print $1 ; exit}' %f` 2>/dev/null case $CHECK in Newsgroups:|Path:) - cp %f /tmp/%f.$$ && sed '/^'"$CHECK"' /,/^$/d' /tmp/%f.$$ > %f - [ "$?" = "0" ] && rm /tmp/%f.$$ + I=`mktemp ${MC_TMPDIR:-/tmp}/news.XXXXXX` || exit 1 + cp %f $I && sed '/^'"$CHECK"' /,/^$/d' $I > %f + [ "$?" = "0" ] && rm $I echo %f: header removed ;; *) @@ -126,7 +128,7 @@ set %t while [ -n "$1" ]; do CHECK=`awk '{print $1 ; exit}' $1` 2>/dev/null - WFILE=/tmp/${1}.$$ + WFILE=`mktemp ${MC_TMPDIR:-/tmp}/news.XXXXXX` || exit 1 case $CHECK in Newsgroups:|Path:) cp $1 $WFILE && sed '/^'"$CHECK"' /,/^$/d' $WFILE > $1 diff -u -r --new-file mc-4.6.0.orig/lib/mcserv.init mc-4.6.0/lib/mcserv.init --- mc-4.6.0.orig/lib/mcserv.init 2002-08-25 20:46:17.000000000 -0700 +++ mc-4.6.0/lib/mcserv.init 2004-05-27 12:49:09.000000000 -0700 @@ -8,7 +8,7 @@ # Michele Marziani # Preston Brown # -# chkconfig: - 86 30 +# chkconfig: 2345 86 30 # description: The Midnight Commander server allows users on remote machines \ # to use the Midnight Commander file manager to manipulate their \ # files on the machine running the server. The server \ diff -u -r --new-file mc-4.6.0.orig/po/az.po mc-4.6.0/po/az.po --- mc-4.6.0.orig/po/az.po 2003-02-05 10:09:44.000000000 -0800 +++ mc-4.6.0/po/az.po 2004-05-27 12:49:31.000000000 -0700 @@ -2411,13 +2411,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " ( %d blok )" +msgid " (%ld block)" +msgstr " ( %ld blok )" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " ( %d blok )" +msgid " (%ld blocks)" +msgstr " ( %ld blok )" #: src/info.c:179 #, c-format @@ -3656,8 +3656,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/be.po mc-4.6.0/po/be.po --- mc-4.6.0.orig/po/be.po 2003-02-05 10:09:44.000000000 -0800 +++ mc-4.6.0/po/be.po 2004-05-27 12:49:31.000000000 -0700 @@ -2404,13 +2404,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d )" +msgid " (%ld block)" +msgstr " (%ld )" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d )" +msgid " (%ld blocks)" +msgstr " (%ld )" #: src/info.c:179 #, c-format @@ -3630,8 +3630,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr " 0x%08x" +msgid "Offset 0x%08lx" +msgstr " 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/bg.po mc-4.6.0/po/bg.po --- mc-4.6.0.orig/po/bg.po 2003-02-05 10:09:45.000000000 -0800 +++ mc-4.6.0/po/bg.po 2004-05-27 12:49:31.000000000 -0700 @@ -2406,13 +2406,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d блок)" +msgid " (%ld block)" +msgstr " (%ld блок)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d блока)" +msgid " (%ld blocks)" +msgstr " (%ld блока)" #: src/info.c:179 #, c-format @@ -3649,8 +3649,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Отместване 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Отместване 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/ca.po mc-4.6.0/po/ca.po --- mc-4.6.0.orig/po/ca.po 2003-02-05 10:09:45.000000000 -0800 +++ mc-4.6.0/po/ca.po 2004-05-27 12:49:31.000000000 -0700 @@ -2416,13 +2416,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d bloc)" +msgid " (%ld block)" +msgstr " (%ld bloc)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blocs)" +msgid " (%ld blocks)" +msgstr " (%ld blocs)" #: src/info.c:179 #, c-format @@ -3670,8 +3670,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Desplaament 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Desplaament 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/cs.po mc-4.6.0/po/cs.po --- mc-4.6.0.orig/po/cs.po 2003-02-05 10:09:45.000000000 -0800 +++ mc-4.6.0/po/cs.po 2004-05-27 12:49:31.000000000 -0700 @@ -2407,13 +2407,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blok)" +msgid " (%ld block)" +msgstr " (%ld blok)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blok)" +msgid " (%ld blocks)" +msgstr " (%ld blok)" #: src/info.c:179 #, c-format @@ -3643,8 +3643,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Posun 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Posun 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/da.po mc-4.6.0/po/da.po --- mc-4.6.0.orig/po/da.po 2003-02-05 10:09:46.000000000 -0800 +++ mc-4.6.0/po/da.po 2004-05-27 12:49:31.000000000 -0700 @@ -1,8 +1,7 @@ -# Danish translation of Midnight Commander -# Copyright (C) 1998 Free Software Foundation, Inc. -# Kenneth Christiansen , 1999-2000 -# Birger Langkjer , 1999. -# Keld Simonsen , 2000. +# Danish translation of Midnight Commander Copyright (C) 1998 Free Software +# Foundation, Inc. Kenneth Christiansen , 1999-2000 Birger +# Langkjer , 1999. Keld Simonsen , +# 2000. # # Note: MC bestr af konsol- (mc) og gtkdel (gmc) # Genveje i konsolen er '&+stort bogstav', resten @@ -2416,13 +2415,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blok)" +msgid " (%ld block)" +msgstr " (%ld blok)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blokke)" +msgid " (%ld blocks)" +msgstr " (%ld blokke)" #: src/info.c:179 #, c-format @@ -3661,8 +3660,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Afstand 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Afstand 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/de.po mc-4.6.0/po/de.po --- mc-4.6.0.orig/po/de.po 2003-02-05 10:09:46.000000000 -0800 +++ mc-4.6.0/po/de.po 2004-05-27 12:49:31.000000000 -0700 @@ -2415,13 +2415,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d Block)" +msgid " (%ld block)" +msgstr " (%ld Block)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr "(%d Blcke)" +msgid " (%ld blocks)" +msgstr "(%ld Blcke)" #: src/info.c:179 #, c-format @@ -3664,8 +3664,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/el.po mc-4.6.0/po/el.po --- mc-4.6.0.orig/po/el.po 2003-02-05 10:09:46.000000000 -0800 +++ mc-4.6.0/po/el.po 2004-05-27 12:49:31.000000000 -0700 @@ -2304,12 +2304,12 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" +msgid " (%ld block)" msgstr "" #: src/info.c:173 #, c-format -msgid " (%d blocks)" +msgid " (%ld blocks)" msgstr "" #: src/info.c:179 @@ -3480,7 +3480,7 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" +msgid "Offset 0x%08lx" msgstr "" #: src/view.c:826 diff -u -r --new-file mc-4.6.0.orig/po/es.po mc-4.6.0/po/es.po --- mc-4.6.0.orig/po/es.po 2003-02-05 10:09:46.000000000 -0800 +++ mc-4.6.0/po/es.po 2004-05-27 12:49:31.000000000 -0700 @@ -2403,13 +2403,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d bloque)" +msgid " (%ld block)" +msgstr " (%ld bloque)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d bloques)" +msgid " (%ld blocks)" +msgstr " (%ld bloques)" #: src/info.c:179 #, c-format @@ -3638,8 +3638,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/eu.po mc-4.6.0/po/eu.po --- mc-4.6.0.orig/po/eu.po 2003-02-05 10:09:46.000000000 -0800 +++ mc-4.6.0/po/eu.po 2004-05-27 12:49:31.000000000 -0700 @@ -2415,13 +2415,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d bloke)" +msgid " (%ld block)" +msgstr " (%ld bloke)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr "(%d bloke)" +msgid " (%ld blocks)" +msgstr "(%ld bloke)" #: src/info.c:179 #, c-format @@ -3665,8 +3665,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Desplazamendua 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Desplazamendua 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/fi.po mc-4.6.0/po/fi.po --- mc-4.6.0.orig/po/fi.po 2003-02-05 10:09:47.000000000 -0800 +++ mc-4.6.0/po/fi.po 2004-05-27 12:49:31.000000000 -0700 @@ -2364,12 +2364,12 @@ #: src/info.c:173 #, fuzzy, c-format -msgid " (%d block)" +msgid " (%ld block)" msgstr " Jrjest valinta " #: src/info.c:173 #, c-format -msgid " (%d blocks)" +msgid " (%ld blocks)" msgstr "" #: src/info.c:179 @@ -3556,8 +3556,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Siirros 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Siirros 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/fr.po mc-4.6.0/po/fr.po --- mc-4.6.0.orig/po/fr.po 2003-02-05 10:09:47.000000000 -0800 +++ mc-4.6.0/po/fr.po 2004-05-27 12:49:31.000000000 -0700 @@ -1288,7 +1288,7 @@ #: src/cmd.c:666 msgid "&Home" -msgstr "Rpertoire &personnel" +msgstr "Rp. &personnel" #: src/cmd.c:738 msgid "Syntax file edit" @@ -2411,13 +2411,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d bloc)" +msgid " (%ld block)" +msgstr " (%ld bloc)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blocs)" +msgid " (%ld blocks)" +msgstr " (%ld blocs)" #: src/info.c:179 #, c-format @@ -3663,8 +3663,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Dcalage 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Dcalage 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/hu.po mc-4.6.0/po/hu.po --- mc-4.6.0.orig/po/hu.po 2003-02-05 10:09:47.000000000 -0800 +++ mc-4.6.0/po/hu.po 2004-05-27 12:49:31.000000000 -0700 @@ -2444,13 +2444,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blokk)" +msgid " (%ld block)" +msgstr " (%ld blokk)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blokk)" +msgid " (%ld blocks)" +msgstr " (%ld blokk)" #: src/info.c:179 #, c-format @@ -3685,8 +3685,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Pozci: 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Pozci: 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/it.po mc-4.6.0/po/it.po --- mc-4.6.0.orig/po/it.po 2003-02-05 10:09:47.000000000 -0800 +++ mc-4.6.0/po/it.po 2004-05-27 12:49:31.000000000 -0700 @@ -2409,13 +2409,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blocchi)" +msgid " (%ld block)" +msgstr " (%ld blocchi)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blocchi)" +msgid " (%ld blocks)" +msgstr " (%ld blocchi)" #: src/info.c:179 #, c-format @@ -3644,8 +3644,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset: 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset: 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/ja.po mc-4.6.0/po/ja.po --- mc-4.6.0.orig/po/ja.po 2003-02-05 10:09:48.000000000 -0800 +++ mc-4.6.0/po/ja.po 2004-05-27 12:49:31.000000000 -0700 @@ -2410,13 +2410,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d֥å)" +msgid " (%ld block)" +msgstr " (%ld֥å)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d֥å)" +msgid " (%ld blocks)" +msgstr " (%ld֥å)" #: src/info.c:179 #, c-format @@ -3654,8 +3654,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "եå 0x%08x" +msgid "Offset 0x%08lx" +msgstr "եå 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/ko.po mc-4.6.0/po/ko.po --- mc-4.6.0.orig/po/ko.po 2003-02-05 10:09:48.000000000 -0800 +++ mc-4.6.0/po/ko.po 2004-05-27 12:49:31.000000000 -0700 @@ -2399,13 +2399,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d )" +msgid " (%ld block)" +msgstr " (%ld )" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d )" +msgid " (%ld blocks)" +msgstr " (%ld )" #: src/info.c:179 #, c-format @@ -3631,8 +3631,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "ɼ 0x%08x" +msgid "Offset 0x%08lx" +msgstr "ɼ 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/lv.po mc-4.6.0/po/lv.po --- mc-4.6.0.orig/po/lv.po 2003-02-05 10:09:48.000000000 -0800 +++ mc-4.6.0/po/lv.po 2004-05-27 12:49:31.000000000 -0700 @@ -2411,13 +2411,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d bloks)" +msgid " (%ld block)" +msgstr " (%ld bloks)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d bloki)" +msgid " (%ld blocks)" +msgstr " (%ld bloki)" #: src/info.c:179 #, c-format @@ -3661,8 +3661,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Nobde 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Nobde 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/nl.po mc-4.6.0/po/nl.po --- mc-4.6.0.orig/po/nl.po 2003-02-05 10:09:48.000000000 -0800 +++ mc-4.6.0/po/nl.po 2004-05-27 12:49:31.000000000 -0700 @@ -2406,13 +2406,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blokken)" +msgid " (%ld block)" +msgstr " (%ld blokken)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr "(%d blokken)" +msgid " (%ld blocks)" +msgstr "(%ld blokken)" #: src/info.c:179 #, c-format @@ -3640,8 +3640,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/no.po mc-4.6.0/po/no.po --- mc-4.6.0.orig/po/no.po 2003-02-05 10:09:49.000000000 -0800 +++ mc-4.6.0/po/no.po 2004-05-27 12:49:31.000000000 -0700 @@ -2405,13 +2405,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blokk)" +msgid " (%ld block)" +msgstr " (%ld blokk)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blokker)" +msgid " (%ld blocks)" +msgstr " (%ld blokker)" #: src/info.c:179 #, c-format @@ -3640,8 +3640,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/pl.po mc-4.6.0/po/pl.po --- mc-4.6.0.orig/po/pl.po 2003-02-05 10:09:49.000000000 -0800 +++ mc-4.6.0/po/pl.po 2004-05-27 12:49:31.000000000 -0700 @@ -2410,13 +2410,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blok)" +msgid " (%ld block)" +msgstr " (%ld blok)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blokw)" +msgid " (%ld blocks)" +msgstr " (%ld blokw)" #: src/info.c:179 #, c-format @@ -3642,8 +3642,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Przesunicie 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Przesunicie 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/pt.po mc-4.6.0/po/pt.po --- mc-4.6.0.orig/po/pt.po 2003-02-05 10:09:49.000000000 -0800 +++ mc-4.6.0/po/pt.po 2004-05-27 12:49:31.000000000 -0700 @@ -2410,13 +2410,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d bloco)" +msgid " (%ld block)" +msgstr " (%ld bloco)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blocos)" +msgid " (%ld blocks)" +msgstr " (%ld blocos)" #: src/info.c:179 #, c-format @@ -3657,8 +3657,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/pt_BR.po mc-4.6.0/po/pt_BR.po --- mc-4.6.0.orig/po/pt_BR.po 2003-02-05 10:09:49.000000000 -0800 +++ mc-4.6.0/po/pt_BR.po 2004-05-27 12:49:31.000000000 -0700 @@ -1300,7 +1300,7 @@ #: src/cmd.c:666 msgid "&Home" -msgstr "Diretrio &Pessoal " +msgstr "Dir &Pessoal " #: src/cmd.c:738 #, fuzzy @@ -2429,13 +2429,13 @@ #: src/info.c:173 #, fuzzy, c-format -msgid " (%d block)" -msgstr " (%d blocos)" +msgid " (%ld block)" +msgstr " (%ld blocos)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blocos)" +msgid " (%ld blocks)" +msgstr " (%ld blocos)" #: src/info.c:179 #, c-format @@ -3691,8 +3691,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Deslocamento 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Deslocamento 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/ro.po mc-4.6.0/po/ro.po --- mc-4.6.0.orig/po/ro.po 2003-02-05 10:09:50.000000000 -0800 +++ mc-4.6.0/po/ro.po 2004-05-27 12:49:31.000000000 -0700 @@ -2403,13 +2403,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blocuri)" +msgid " (%ld block)" +msgstr " (%ld blocuri)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blocuri)" +msgid " (%ld blocks)" +msgstr " (%ld blocuri)" #: src/info.c:179 #, c-format @@ -3638,8 +3638,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/ru.po mc-4.6.0/po/ru.po --- mc-4.6.0.orig/po/ru.po 2003-02-05 10:09:50.000000000 -0800 +++ mc-4.6.0/po/ru.po 2004-05-27 12:49:31.000000000 -0700 @@ -2411,13 +2411,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d )" +msgid " (%ld block)" +msgstr " (%ld )" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d )" +msgid " (%ld blocks)" +msgstr " (%ld )" #: src/info.c:179 #, c-format @@ -3644,8 +3644,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr " 0x%08x" +msgid "Offset 0x%08lx" +msgstr " 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/sk.po mc-4.6.0/po/sk.po --- mc-4.6.0.orig/po/sk.po 2003-02-05 10:09:50.000000000 -0800 +++ mc-4.6.0/po/sk.po 2004-05-27 12:49:31.000000000 -0700 @@ -2402,13 +2402,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blok)" +msgid " (%ld block)" +msgstr " (%ld blok)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blokov)" +msgid " (%ld blocks)" +msgstr " (%ld blokov)" #: src/info.c:179 #, c-format @@ -3634,8 +3634,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/sl.po mc-4.6.0/po/sl.po --- mc-4.6.0.orig/po/sl.po 2003-02-05 10:09:50.000000000 -0800 +++ mc-4.6.0/po/sl.po 2004-05-27 12:49:31.000000000 -0700 @@ -2405,13 +2405,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blokov)" +msgid " (%ld block)" +msgstr " (%ld blokov)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blokov)" +msgid " (%ld blocks)" +msgstr " (%ld blokov)" #: src/info.c:179 #, c-format @@ -3640,8 +3640,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/sv.po mc-4.6.0/po/sv.po --- mc-4.6.0.orig/po/sv.po 2003-02-05 10:09:51.000000000 -0800 +++ mc-4.6.0/po/sv.po 2004-05-27 12:49:31.000000000 -0700 @@ -2434,13 +2434,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d block)" +msgid " (%ld block)" +msgstr " (%ld block)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d block)" +msgid " (%ld blocks)" +msgstr " (%ld block)" #: src/info.c:179 #, c-format @@ -3678,8 +3678,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" # svngelska? #: src/view.c:826 diff -u -r --new-file mc-4.6.0.orig/po/ta.po mc-4.6.0/po/ta.po --- mc-4.6.0.orig/po/ta.po 2003-02-05 10:09:51.000000000 -0800 +++ mc-4.6.0/po/ta.po 2004-05-27 12:49:31.000000000 -0700 @@ -2307,12 +2307,12 @@ #: src/info.c:173 #, fuzzy, c-format -msgid " (%d block)" +msgid " (%ld block)" msgstr " ̾ š¡ " #: src/info.c:173 #, c-format -msgid " (%d blocks)" +msgid " (%ld blocks)" msgstr "" #: src/info.c:179 @@ -3483,7 +3483,7 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" +msgid "Offset 0x%08lx" msgstr "" #: src/view.c:826 diff -u -r --new-file mc-4.6.0.orig/po/tr.po mc-4.6.0/po/tr.po --- mc-4.6.0.orig/po/tr.po 2003-02-05 10:09:51.000000000 -0800 +++ mc-4.6.0/po/tr.po 2004-05-27 12:49:31.000000000 -0700 @@ -2409,13 +2409,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blok)" +msgid " (%ld block)" +msgstr " (%ld blok)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d blok)" +msgid " (%ld blocks)" +msgstr " (%ld blok)" #: src/info.c:179 #, c-format @@ -3655,8 +3655,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "Offset 0x%08x" +msgid "Offset 0x%08lx" +msgstr "Offset 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/uk.po mc-4.6.0/po/uk.po --- mc-4.6.0.orig/po/uk.po 2003-02-05 10:09:51.000000000 -0800 +++ mc-4.6.0/po/uk.po 2004-05-27 12:49:31.000000000 -0700 @@ -2399,13 +2399,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d )" +msgid " (%ld block)" +msgstr " (%ld )" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d ˦)" +msgid " (%ld blocks)" +msgstr " (%ld ˦)" #: src/info.c:179 #, c-format @@ -3632,8 +3632,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "ͦ 0x%08x" +msgid "Offset 0x%08lx" +msgstr "ͦ 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/wa.po mc-4.6.0/po/wa.po --- mc-4.6.0.orig/po/wa.po 2003-02-05 10:09:52.000000000 -0800 +++ mc-4.6.0/po/wa.po 2004-05-27 12:49:31.000000000 -0700 @@ -2425,13 +2425,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d blok)" +msgid " (%ld block)" +msgstr " (%ld blok)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d bloks)" +msgid " (%ld blocks)" +msgstr " (%ld bloks)" #: src/info.c:179 #, c-format @@ -3650,7 +3650,7 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" +msgid "Offset 0x%08lx" msgstr "" #: src/view.c:826 diff -u -r --new-file mc-4.6.0.orig/po/zh_CN.po mc-4.6.0/po/zh_CN.po --- mc-4.6.0.orig/po/zh_CN.po 2003-02-05 10:09:52.000000000 -0800 +++ mc-4.6.0/po/zh_CN.po 2004-05-27 12:49:31.000000000 -0700 @@ -2396,13 +2396,13 @@ #: src/info.c:173 #, c-format -msgid " (%d block)" -msgstr " (%d 个块)" +msgid " (%ld block)" +msgstr " (%ld 个块)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d 个块)" +msgid " (%ld blocks)" +msgstr " (%ld 个块)" #: src/info.c:179 #, c-format @@ -3629,8 +3629,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr "偏移 0x%08x" +msgid "Offset 0x%08lx" +msgstr "偏移 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/po/zh_TW.po mc-4.6.0/po/zh_TW.po --- mc-4.6.0.orig/po/zh_TW.po 2003-02-05 10:09:52.000000000 -0800 +++ mc-4.6.0/po/zh_TW.po 2004-05-27 12:49:31.000000000 -0700 @@ -2407,13 +2407,13 @@ #: src/info.c:173 #, fuzzy, c-format -msgid " (%d block)" -msgstr " (%d Ӱ϶)" +msgid " (%ld block)" +msgstr " (%ld Ӱ϶)" #: src/info.c:173 #, c-format -msgid " (%d blocks)" -msgstr " (%d Ӱ϶)" +msgid " (%ld blocks)" +msgstr " (%ld Ӱ϶)" #: src/info.c:179 #, c-format @@ -3655,8 +3655,8 @@ #: src/view.c:824 #, c-format -msgid "Offset 0x%08x" -msgstr " 0x%08x" +msgid "Offset 0x%08lx" +msgstr " 0x%08lx" #: src/view.c:826 #, c-format diff -u -r --new-file mc-4.6.0.orig/slang/sltermin.c mc-4.6.0/slang/sltermin.c --- mc-4.6.0.orig/slang/sltermin.c 2002-10-07 04:08:16.000000000 -0700 +++ mc-4.6.0/slang/sltermin.c 2004-05-27 12:49:31.000000000 -0700 @@ -267,9 +267,12 @@ if (NULL != (home = getenv ("HOME"))) { - strncpy (home_ti, home, sizeof (home_ti) - 11); - home_ti [sizeof(home_ti) - 11] = 0; - strcat (home_ti, "/.terminfo"); + size_t len = strlen (home); + + if (len > sizeof (home_ti) - sizeof ("/.terminfo")) + len = sizeof (home_ti) - sizeof ("/.terminfo"); + memcpy (home_ti, home, len); + memcpy (home_ti + len, "/.terminfo", sizeof ("/.terminfo")); Terminfo_Dirs [0] = home_ti; } diff -u -r --new-file mc-4.6.0.orig/src/cmd.c mc-4.6.0/src/cmd.c --- mc-4.6.0.orig/src/cmd.c 2003-02-05 07:54:33.000000000 -0800 +++ mc-4.6.0/src/cmd.c 2004-05-27 12:49:30.000000000 -0700 @@ -1132,7 +1132,7 @@ q = g_strdup_printf (_(" Symlink `%s\' points to: "), name_trunc (p, 32)); - i = readlink (p, buffer, MC_MAXPATHLEN); + i = readlink (p, buffer, MC_MAXPATHLEN - 1); if (i > 0) { buffer [i] = 0; dest = input_expand_dialog (_(" Edit symlink "), q, buffer); diff -u -r --new-file mc-4.6.0.orig/src/command.c mc-4.6.0/src/command.c --- mc-4.6.0.orig/src/command.c 2002-11-13 23:25:19.000000000 -0800 +++ mc-4.6.0/src/command.c 2004-05-27 12:49:30.000000000 -0700 @@ -258,7 +258,7 @@ WInput * command_new (int y, int x, int cols) { - WInput *cmd = g_new (WInput, 1); + WInput *cmd; cmd = input_new (y, x, DEFAULT_COLOR, cols, "", "cmdline"); diff -u -r --new-file mc-4.6.0.orig/src/complete.c mc-4.6.0/src/complete.c --- mc-4.6.0.orig/src/complete.c 2002-11-12 18:56:41.000000000 -0800 +++ mc-4.6.0/src/complete.c 2004-05-27 12:49:30.000000000 -0700 @@ -270,7 +270,7 @@ *temp = '$'; if (isbrace) temp [1] = '{'; - strncpy (temp + 1 + isbrace, *env_p, p - *env_p); + memcpy (temp + 1 + isbrace, *env_p, p - *env_p); if (isbrace) strcpy (temp + 2 + (p - *env_p), "}"); else @@ -605,8 +605,7 @@ matches = i; match_list [matches + 1] = NULL; match_list[0] = g_malloc (low + 1); - strncpy (match_list[0], match_list[1], low); - match_list[0][low] = 0; + g_strlcpy (match_list[0], match_list[1], low + 1); } } else { /* There were no matches. */ g_free (match_list); @@ -806,7 +805,7 @@ *(p++) = *(q++); *p = 0; } - strncpy (in->buffer + start, text, len - start + end); + memcpy (in->buffer + start, text, len - start + end); in->point += len; update_input (in, 1); end += len; diff -u -r --new-file mc-4.6.0.orig/src/dir.c mc-4.6.0/src/dir.c --- mc-4.6.0.orig/src/dir.c 2003-01-20 16:41:45.000000000 -0800 +++ mc-4.6.0/src/dir.c 2004-05-27 12:49:30.000000000 -0700 @@ -503,9 +503,11 @@ } if (next_free) { + char *path = vfs_canon ("."); /* Add ".." except the root directory */ - if (strcmp (vfs_canon ("."), "/") != 0) + if (strcmp (path, "/") != 0) add_dotdot_to_list (list, next_free++); + g_free (path); do_sort (list, sort, next_free - 1, reverse, case_sensitive); } else { tree_store_end_check (); @@ -576,7 +578,7 @@ int i, status, link_to_dir, stale_link; struct stat buf; int marked_cnt; - GHashTable *marked_files = g_hash_table_new (g_str_hash, g_str_equal); + GHashTable *marked_files; tree_store_start_check_cwd (); dirp = mc_opendir ("."); @@ -587,6 +589,7 @@ return set_zero_dir (list); } + marked_files = g_hash_table_new (g_str_hash, g_str_equal); alloc_dir_copy (list->size); for (marked_cnt = i = 0; i < count; i++) { dir_copy.list[i].fnamelen = list->list[i].fnamelen; @@ -622,6 +625,7 @@ clean_dir (&dir_copy, count); */ tree_store_end_check (); + g_hash_table_destroy (marked_files); return next_free; } @@ -655,9 +659,11 @@ tree_store_end_check (); g_hash_table_destroy (marked_files); if (next_free) { + char *path = vfs_canon ("."); /* Add ".." except the root directory */ - if (strcmp (vfs_canon ("."), "/") != 0) + if (strcmp (path, "/") != 0) add_dotdot_to_list (list, next_free++); + g_free (path); do_sort (list, sort, next_free - 1, rev, case_sensitive); } else next_free = set_zero_dir (list); diff -u -r --new-file mc-4.6.0.orig/src/ext.c mc-4.6.0/src/ext.c --- mc-4.6.0.orig/src/ext.c 2002-11-13 23:25:19.000000000 -0800 +++ mc-4.6.0/src/ext.c 2004-05-27 12:49:30.000000000 -0700 @@ -477,7 +477,6 @@ int found = 0; int error_flag = 0; int ret = 0; - int old_patterns; struct stat mystat; int view_at_line_number; char *include_target; @@ -559,8 +558,6 @@ } mc_stat (filename, &mystat); - old_patterns = easy_patterns; - easy_patterns = 0; /* Real regular expressions are needed :) */ include_target = NULL; include_target_len = 0; for (p = data; *p; p++) { @@ -593,11 +590,11 @@ /* Do not transform shell patterns, you can use shell/ for * that */ - if (regexp_match (p, filename, match_normal)) + if (regexp_match (p, filename, match_regex)) found = 1; } else if (!strncmp (p, "directory/", 10)) { if (S_ISDIR (mystat.st_mode) - && regexp_match (p + 10, filename, match_normal)) + && regexp_match (p + 10, filename, match_regex)) found = 1; } else if (!strncmp (p, "shell/", 6)) { p += 6; @@ -683,7 +680,6 @@ break; } } - easy_patterns = old_patterns; if (error_flag) return -1; return ret; diff -u -r --new-file mc-4.6.0.orig/src/file.c mc-4.6.0/src/file.c --- mc-4.6.0.orig/src/file.c 2002-12-26 11:04:10.000000000 -0800 +++ mc-4.6.0/src/file.c 2004-05-27 12:49:30.000000000 -0700 @@ -366,7 +366,7 @@ dst_is_symlink = 0; retry_src_readlink: - len = mc_readlink (src_path, link_target, MC_MAXPATHLEN); + len = mc_readlink (src_path, link_target, MC_MAXPATHLEN - 1); if (len < 0) { return_status = file_error (_(" Cannot read source link \"%s\" \n %s "), @@ -715,6 +715,7 @@ gettimeofday (&tv_current, NULL); if (n_read > 0) { + char *t = buf; n_read_total += n_read; /* Windows NT ftp servers report that files have no @@ -729,9 +730,10 @@ /* dst_write */ while ((n_written = - mc_write (dest_desc, buf, n_read)) < n_read) { + mc_write (dest_desc, t, n_read)) < n_read) { if (n_written > 0) { n_read -= n_written; + t += n_written; continue; } return_status = diff -u -r --new-file mc-4.6.0.orig/src/find.c mc-4.6.0/src/find.c --- mc-4.6.0.orig/src/find.c 2002-12-24 03:28:26.000000000 -0800 +++ mc-4.6.0/src/find.c 2004-05-27 12:49:30.000000000 -0700 @@ -312,7 +312,7 @@ dir_stack *new; new = g_new (dir_stack, 1); - new->name = g_strdup (dir); + new->name = concat_dir_and_file (dir, ""); new->prev = dir_stack_base; dir_stack_base = new; } @@ -338,17 +338,9 @@ { char *tmp_name; static char *dirname; - int i; - if (dir [0] == PATH_SEP && dir [1] == PATH_SEP) + while (dir [0] == PATH_SEP && dir [1] == PATH_SEP) dir++; - i = strlen (dir); - if (i){ - if (dir [i - 1] != PATH_SEP){ - dir [i] = PATH_SEP; - dir [i + 1] = 0; - } - } if (old_dir){ if (strcmp (old_dir, dir)){ @@ -401,7 +393,7 @@ char ch = 0; int i = 0; - do { + for (;;) { if (*pos >= *n_read){ *pos = 0; if ((*n_read = mc_read (file_fd, buf, buf_size)) <= 0) @@ -420,10 +412,12 @@ if (i >= buffer_size - 1){ buffer = g_realloc (buffer, buffer_size += 80); } + /* Strip newline to fix $ matching */ + if (ch == '\n') + break; buffer [i++] = ch; - - } while (ch != '\n'); + } *has_newline = ch ? 1 : 0; @@ -502,7 +496,7 @@ { static struct dirent *dp = 0; static DIR *dirp = 0; - static char directory [MC_MAXPATHLEN+2]; + static char *directory; struct stat tmp_stat; static int pos; static int subdirs_left = 0; @@ -513,6 +507,10 @@ mc_closedir (dirp); dirp = 0; } + if (directory) { + g_free (directory); + directory = NULL; + } dp = 0; return 1; } @@ -550,8 +548,9 @@ break; } - strcpy (directory, tmp); - g_free (tmp); + if (directory) + g_free (directory); + directory = tmp; if (verbose){ char buffer [BUF_SMALL]; @@ -582,8 +581,8 @@ tmp_name = concat_dir_and_file (directory, dp->d_name); if (subdirs_left){ - mc_lstat (tmp_name, &tmp_stat); - if (S_ISDIR (tmp_stat.st_mode)){ + if (!mc_lstat (tmp_name, &tmp_stat) + && S_ISDIR (tmp_stat.st_mode)){ push_directory (tmp_name); subdirs_left--; } diff -u -r --new-file mc-4.6.0.orig/src/info.c mc-4.6.0/src/info.c --- mc-4.6.0.orig/src/info.c 2003-01-28 14:58:22.000000000 -0800 +++ mc-4.6.0/src/info.c 2004-05-27 12:49:30.000000000 -0700 @@ -123,7 +123,7 @@ size_trunc_len (buffer1, 5, myfs_stats.avail, 1); size_trunc_len (buffer2, 5, myfs_stats.total, 1); printw (_("Free space: %s (%d%%) of %s"), buffer1, myfs_stats.total ? - 100 * myfs_stats.avail / myfs_stats.total : 0, buffer2); + (int) (100.0 * myfs_stats.avail / myfs_stats.total) : 0, buffer2); } else addstr (_("No space information")); @@ -170,7 +170,7 @@ printw (_("Size: %s"), buffer); #ifdef HAVE_ST_BLOCKS printw ((buf.st_blocks==1) ? - _(" (%d block)") : _(" (%d blocks)"), buf.st_blocks); + _(" (%ld block)") : _(" (%ld blocks)"), (long) buf.st_blocks); #endif } diff -u -r --new-file mc-4.6.0.orig/src/main.c mc-4.6.0/src/main.c --- mc-4.6.0.orig/src/main.c 2003-02-05 07:54:34.000000000 -0800 +++ mc-4.6.0/src/main.c 2004-05-27 12:49:30.000000000 -0700 @@ -1300,7 +1300,7 @@ concat_dir_and_file (panel->cwd, selection (panel)->fname); int i; - i = mc_readlink (p, buffer, MC_MAXPATHLEN); + i = mc_readlink (p, buffer, MC_MAXPATHLEN - 1); g_free (p); if (i > 0) { buffer[i] = 0; diff -u -r --new-file mc-4.6.0.orig/src/man2hlp.c mc-4.6.0/src/man2hlp.c --- mc-4.6.0.orig/src/man2hlp.c 2003-01-20 15:23:42.000000000 -0800 +++ mc-4.6.0/src/man2hlp.c 2004-05-27 12:49:30.000000000 -0700 @@ -611,8 +611,7 @@ /* Bold text or italics text */ if (buffer[0] == '.' && (buffer[1] == 'I' || buffer[1] == 'B')) for (buffer += 2; *buffer == ' ' || *buffer == '\t'; buffer++); - strncpy (old, buffer, sizeof (old) - 1); - old[sizeof (old) - 1] = 0; + g_strlcpy (old, buffer, sizeof (old)); link_flag = 3; break; case 3: diff -u -r --new-file mc-4.6.0.orig/src/profile.c mc-4.6.0/src/profile.c --- mc-4.6.0.orig/src/profile.c 2003-01-20 06:33:02.000000000 -0800 +++ mc-4.6.0/src/profile.c 2004-05-27 12:49:30.000000000 -0700 @@ -325,8 +325,7 @@ s = GetSetProfileChar (set, AppName, KeyName, Default, FileName); if (!set){ - ReturnedString [Size-1] = 0; - strncpy (ReturnedString, s, Size-1); + g_strlcpy (ReturnedString, s, Size); } return 1; } diff -u -r --new-file mc-4.6.0.orig/src/screen.c mc-4.6.0/src/screen.c --- mc-4.6.0.orig/src/screen.c 2003-01-28 14:58:22.000000000 -0800 +++ mc-4.6.0/src/screen.c 2004-05-27 12:49:30.000000000 -0700 @@ -672,7 +672,7 @@ int len; link = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname); - len = mc_readlink (link, link_target, MC_MAXPATHLEN); + len = mc_readlink (link, link_target, MC_MAXPATHLEN - 1); g_free (link); if (len > 0){ link_target[len] = 0; @@ -1045,7 +1045,6 @@ int spaces, extra; int side, width; - char *txt, buffer[30]; /*Hope that this is enough ;-) */ if (!panel->split) adjust_top_file (panel); @@ -1068,21 +1067,16 @@ for (format = panel->format; format; format = format->next){ if (format->string_fn){ - txt = format->title; - - header_len = strlen (txt); + header_len = strlen (format->title); if (header_len > format->field_len){ - strcpy (buffer, txt); - txt = buffer; - txt [format->field_len] = 0; - header_len = strlen (txt); + header_len = format->field_len; } attrset (MARKED_COLOR); spaces = (format->field_len - header_len) / 2; extra = (format->field_len - header_len) % 2; - printw ("%*s%-s%*s", spaces, "", - txt, spaces+extra, ""); + printw ("%*s%.*s%*s", spaces, "", + header_len, format->title, spaces+extra, ""); width -= 2 * spaces + extra + header_len; } else { attrset (NORMAL_COLOR); @@ -2021,7 +2015,7 @@ int i; struct stat mybuf; - i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN); + i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN - 1); if (i < 0) return; if (mc_stat (selection (panel)->fname, &mybuf) < 0) diff -u -r --new-file mc-4.6.0.orig/src/subshell.c mc-4.6.0/src/subshell.c --- mc-4.6.0.orig/src/subshell.c 2003-01-24 13:37:28.000000000 -0800 +++ mc-4.6.0/src/subshell.c 2004-05-27 12:49:30.000000000 -0700 @@ -710,7 +710,9 @@ } g_free (subshell_prompt); + g_free (pty_buffer); subshell_prompt = NULL; + pty_buffer = NULL; return quit; } diff -u -r --new-file mc-4.6.0.orig/src/user.c mc-4.6.0/src/user.c --- mc-4.6.0.orig/src/user.c 2002-11-28 19:03:53.000000000 -0800 +++ mc-4.6.0/src/user.c 2004-05-27 12:49:30.000000000 -0700 @@ -138,19 +138,14 @@ } /* Copy the variable name */ - var_name = g_malloc (dots - p); - strncpy (var_name, p+4, dots-2 - (p+3)); - var_name [dots-2 - (p+3)] = 0; - + var_name = g_strndup (p + 4, dots - p - 5); value = getenv (var_name); g_free (var_name); if (value){ *v = g_strdup (value); return q-p; } - var_name = g_malloc (q - dots + 1); - strncpy (var_name, dots, q - dots + 1); - var_name [q-dots] = 0; + var_name = g_strndup (dots, q - dots); *v = var_name; return q-p; } @@ -300,13 +295,15 @@ /* Copies a whitespace separated argument from p to arg. Returns the point after argument. */ -static char *extract_arg (char *p, char *arg) +static char *extract_arg (char *p, char *arg, size_t size) { while (*p && (*p == ' ' || *p == '\t' || *p == '\n')) p++; /* support quote space .mnu */ - while (*p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n') + while (size > 1 && *p && (*p != ' ' || *(p-1) == '\\') && *p != '\t' && *p != '\n') { *arg++ = *p++; + size--; + } *arg = 0; if (!*p || *p == '\n') p --; @@ -389,29 +386,29 @@ p--; break; case 'f': /* file name pattern */ - p = extract_arg (p, arg); + p = extract_arg (p, arg, sizeof (arg)); *condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file); break; case 'y': /* syntax pattern */ if (edit_widget && edit_widget->syntax_type) { - p = extract_arg (p, arg); + p = extract_arg (p, arg, sizeof (arg)); *condition = panel && regexp_match (arg, edit_widget->syntax_type, match_normal); } break; case 'd': - p = extract_arg (p, arg); + p = extract_arg (p, arg, sizeof (arg)); *condition = panel && regexp_match (arg, panel->cwd, match_file); break; case 't': - p = extract_arg (p, arg); + p = extract_arg (p, arg, sizeof (arg)); *condition = panel && test_type (panel, arg); break; case 'x': /* executable */ { struct stat status; - p = extract_arg (p, arg); + p = extract_arg (p, arg, sizeof (arg)); if (stat (arg, &status) == 0) *condition = is_exe (status.st_mode); else @@ -431,50 +428,43 @@ static void debug_out (char *start, char *end, int cond) { - static char msg [256]; + static char *msg; int len; if (start == NULL && end == NULL){ - if (cond == 0){ - /* Init */ - msg [0] = 0; - } else { - /* Show output */ - if (!debug_flag) - return; + /* Show output */ + if (debug_flag && msg) { len = strlen (msg); if (len) msg [len - 1] = 0; message (0, _(" Debug "), "%s", msg); - debug_flag = 0; } + debug_flag = 0; + g_free (msg); + msg = NULL; } else { + char *type, *p; + /* Save debug info for later output */ if (!debug_flag) return; /* Save the result of the condition */ if (debug_error){ - strcat (msg, _(" ERROR: ")); + type = _(" ERROR: "); debug_error = 0; } else if (cond) - strcat (msg, _(" True: ")); + type = _(" True: "); else - strcat (msg, _(" False: ")); - /* Copy condition statement */ - len = strlen (msg); - if (end == NULL){ - /* Copy one character */ - msg [len] = *start; - msg [len + 1] = 0; - } else { - /* Copy many characters */ - while (start < end){ - msg [len++] = *start++; - } - msg [len] = 0; - } - strcat (msg, " \n"); + type = _(" False: "); + /* This is for debugging, don't need to be super efficient. */ + if (end == NULL) + p = g_strdup_printf ("%s%s%c \n", msg ? msg : "", type, *start); + else + p = g_strdup_printf ("%s%s%.*s \n", msg ? msg : "", type, + (int) (end - start), start); + g_free (msg); + msg = p; } } @@ -486,8 +476,6 @@ char operator; char *debug_start, *debug_end; - /* Init debugger */ - debug_out (NULL, NULL, 0); /* Repeat till end of line */ while (*p && *p != '\n') { /* support quote space .mnu */ @@ -578,6 +566,8 @@ break; while (*commands == ' ' || *commands == '\t') commands++; + if (*commands == '0') + break; } col++; if (*commands == '\n') @@ -734,7 +724,7 @@ } else if (*p == '+'){ if (*(p+1) == '='){ /* Combined adding and default */ - p = test_line (edit_widget, p, &accept_entry); + p = test_line (edit_widget, p + 1, &accept_entry); if (selected == 0 && accept_entry) selected = menu_lines; } else { @@ -744,7 +734,7 @@ } else if (*p == '='){ if (*(p+1) == '+'){ /* Combined adding and default */ - p = test_line (edit_widget, p, &accept_entry); + p = test_line (edit_widget, p + 1, &accept_entry); if (selected == 0 && accept_entry) selected = menu_lines; } else { diff -u -r --new-file mc-4.6.0.orig/src/util.c mc-4.6.0/src/util.c --- mc-4.6.0.orig/src/util.c 2003-01-28 14:58:23.000000000 -0800 +++ mc-4.6.0/src/util.c 2004-05-27 12:49:30.000000000 -0700 @@ -498,7 +498,7 @@ char *new_pattern; int was_wildcard = 0; - if (easy_patterns){ + if ((match_type != match_regex) && easy_patterns){ new_pattern = g_malloc (MC_MAXPATHLEN); d = new_pattern; if (match_type == match_file) @@ -848,7 +848,7 @@ return NULL; } - strncpy (buffer, p, len); + memcpy (buffer, p, len); g_free (p); return buffer; @@ -1063,7 +1063,7 @@ if (!S_ISLNK (mybuf.st_mode)) strcpy (r, p + 1); else { - len = mc_readlink (path, buf2, MC_MAXPATHLEN); + len = mc_readlink (path, buf2, MC_MAXPATHLEN - 1); if (len < 0) { g_free (buf); g_free (buf2); diff -u -r --new-file mc-4.6.0.orig/src/util.h mc-4.6.0/src/util.h --- mc-4.6.0.orig/src/util.h 2003-01-27 13:07:29.000000000 -0800 +++ mc-4.6.0/src/util.h 2004-05-27 12:49:30.000000000 -0700 @@ -62,7 +62,7 @@ #define icase_search(T,D) _icase_search((T), (D), NULL) /* Matching */ -enum { match_file, match_normal }; +enum { match_file, match_normal, match_regex }; extern int easy_patterns; char *convert_pattern (char *pattern, int match_type, int do_group); int regexp_match (char *pattern, char *string, int match_type); diff -u -r --new-file mc-4.6.0.orig/src/utilunix.c mc-4.6.0/src/utilunix.c --- mc-4.6.0.orig/src/utilunix.c 2002-12-26 06:47:46.000000000 -0800 +++ mc-4.6.0/src/utilunix.c 2004-05-27 12:49:30.000000000 -0700 @@ -280,9 +280,7 @@ if (!p){ passwd = getpwnam (directory); } else { - name = g_malloc (p - directory + 1); - strncpy (name, directory, p - directory); - name [p - directory] = 0; + name = g_strndup (directory, p - directory); passwd = getpwnam (name); g_free (name); } @@ -298,7 +296,7 @@ /* * Return the directory where mc should keep its temporary files. - * This directory is (in Bourne shell terms) "${TMPDIR=/tmp}-$USER" + * This directory is (in Bourne shell terms) "${TMPDIR=/tmp}/mc-$USER" * When called the first time, the directory is created if needed. * The first call should be done early, since we are using fprintf() * and not message() to report possible problems. @@ -372,6 +370,7 @@ if (fallback_ok) { fprintf (stderr, _("Temporary files will be created in %s\n"), sys_tmp); + error = NULL; } else { fprintf (stderr, _("Temporary files will not be created\n")); tmpdir = "/dev/null/"; @@ -381,6 +380,9 @@ getc (stdin); } + if (!error) + setenv ("MC_TMPDIR", tmpdir, 1); + return tmpdir; } diff -u -r --new-file mc-4.6.0.orig/src/view.c mc-4.6.0/src/view.c --- mc-4.6.0.orig/src/view.c 2002-12-26 22:48:33.000000000 -0800 +++ mc-4.6.0/src/view.c 2004-05-27 12:49:30.000000000 -0700 @@ -74,6 +74,10 @@ # define IFAIX(x) #endif +#if GLIB_MAJOR_VERSION < 2 +# define g_try_malloc g_malloc +#endif + #define vwidth (view->widget.cols - (view->have_frame ? 2 : 0)) #define vheight (view->widget.lines - (view->have_frame ? 2 : 0)) @@ -308,7 +312,7 @@ view->block_ptr = g_realloc (view->block_ptr, sizeof (block_ptr_t) * page); for (i = view->blocks; i < page; i++) { - char *p = g_malloc (VIEW_PAGE_SIZE); + char *p = g_try_malloc (VIEW_PAGE_SIZE); view->block_ptr[i].data = p; if (!p) return '\n'; @@ -336,7 +340,7 @@ } view->blocks = page; } - if (byte_index > view->bytes_read) { + if (byte_index >= view->bytes_read) { return -1; } else return view->block_ptr[page - 1].data[offset]; @@ -589,7 +593,11 @@ * file into memory (alex@bcs.zaporizhzhe.ua). Also, mmap can fail * for any reason, so we use this as fallback (pavel@ucw.cz) */ - view->data = (unsigned char *) g_malloc (view->s.st_size); + if ((gulong) view->s.st_size == view->s.st_size) + view->data = (unsigned char *) g_try_malloc (view->s.st_size); + else + view->data = NULL; + if (view->data == NULL || mc_lseek (view->file, 0, SEEK_SET) != 0 || mc_read (view->file, view->data, @@ -821,7 +829,7 @@ if (w > 46) { widget_move (view, view->have_frame, 24 + view->have_frame); if (view->hex_mode) - printw (_("Offset 0x%08x"), view->edit_cursor); + printw (_("Offset 0x%08lx"), view->edit_cursor); else printw (_("Col %d"), -view->start_col); } @@ -1513,33 +1521,41 @@ long i = 0; int prev = 0; + if (!pos && direction == -1) + return 0; + /* skip over all the possible zeros in the file */ while ((ch = get_byte (view, pos)) == 0) { + if (!pos && direction == -1) + return 0; pos += direction; i++; } *skipped = i; - if (pos) { - prev = get_byte (view, pos - 1); + if (!i && (pos || direction == -1)) { + prev = get_byte (view, pos - direction); if ((prev == -1) || (prev == '\n')) prev = 0; } - for (i = 0; ch != -1; ch = get_byte (view, pos)) { + for (i = 1; ch != -1; ch = get_byte (view, pos)) { - if (i == usable_size) { + if (i >= usable_size) { buffer = grow_string_buffer (buffer, &buffer_size); usable_size = buffer_size - 2; } + buffer[i++] = ch; + if (!pos && direction == -1) + break; + pos += direction; - i++; if (ch == '\n' || !ch) { + i--; break; } - buffer[i] = ch; } if (buffer) { buffer[0] = prev; diff -u -r --new-file mc-4.6.0.orig/src/widget.c mc-4.6.0/src/widget.c --- mc-4.6.0.orig/src/widget.c 2002-12-25 15:15:48.000000000 -0800 +++ mc-4.6.0/src/widget.c 2004-05-27 12:49:30.000000000 -0700 @@ -607,7 +607,7 @@ if (!g->shown) printw ("%*s", gauge_len, ""); else { - long percentage, columns; + int percentage, columns; long total = g->max, done = g->current; if (total <= 0 || done < 0) { @@ -1255,10 +1255,11 @@ { int first = min (x_first, x_last); int last = max (x_first, x_last); + size_t len = strlen (&in->buffer [last]) + 1; in->point = first; in->mark = first; - strcpy (&in->buffer [first], &in->buffer [last]); + memmove (&in->buffer [first], &in->buffer [last], len); in->need_push = 1; } diff -u -r --new-file mc-4.6.0.orig/src/wtools.c mc-4.6.0/src/wtools.c --- mc-4.6.0.orig/src/wtools.c 2002-11-13 23:25:19.000000000 -0800 +++ mc-4.6.0/src/wtools.c 2004-05-27 12:49:30.000000000 -0700 @@ -412,8 +412,7 @@ /* we need a unique name for tkname because widget.c:history_tool() needs a unique name for each dialog - using the header is ideal */ - strncpy (tk_name + 3, header, 60); - tk_name[63] = '\0'; + g_strlcpy (tk_name + 3, header, 61); quick_widgets[2].tkname = tk_name; len = max (strlen (header), msglen (text, &lines)) + 4; diff -u -r --new-file mc-4.6.0.orig/vfs/cpio.c mc-4.6.0/vfs/cpio.c --- mc-4.6.0.orig/vfs/cpio.c 2002-12-07 17:12:28.000000000 -0800 +++ mc-4.6.0/vfs/cpio.c 2004-05-27 12:49:30.000000000 -0700 @@ -103,9 +103,9 @@ static struct defer_inode * defer_find(struct defer_inode *l, struct defer_inode *i) { - if(!l) return NULL; - return l->inumber == i->inumber && l->device == i->device ? l : - defer_find(l->next, i); + while (l && (l->inumber != i->inumber || l->device != i->device)) + l = l->next; + return l; } static int cpio_skip_padding(vfs_s_super *super) @@ -127,8 +127,14 @@ static void cpio_free_archive(vfs *me, vfs_s_super *super) { + struct defer_inode *l, *lnext; if(super->u.cpio.fd != -1) - mc_close(super->u.cpio.fd); + mc_close(super->u.cpio.fd), super->u.cpio.fd = -1; + for (l = super->u.cpio.defered; l; l = lnext) { + lnext = l->next; + g_free (l); + } + super->u.cpio.defered = NULL; } static int cpio_open_cpio_file(vfs *me, vfs_s_super *super, char *name) @@ -246,26 +252,34 @@ #define HEAD_LENGTH (26) static int cpio_read_bin_head(vfs *me, vfs_s_super *super) { - struct old_cpio_header buf; + union { + struct old_cpio_header buf; + short shorts[HEAD_LENGTH >> 1]; + } u; int len; char *name; struct stat stat; - if((len = mc_read(super->u.cpio.fd, (char *)&buf, HEAD_LENGTH)) < HEAD_LENGTH) + if((len = mc_read(super->u.cpio.fd, (char *)&u.buf, HEAD_LENGTH)) < HEAD_LENGTH) return STATUS_EOF; CPIO_POS(super) += len; if(super->u.cpio.type == CPIO_BINRE) { int i; for(i = 0; i < (HEAD_LENGTH >> 1); i++) - ((short *)&buf)[i] = GUINT16_SWAP_LE_BE(((short *)&buf)[i]); + u.shorts[i] = GUINT16_SWAP_LE_BE(u.shorts[i]); } - g_assert(buf.c_magic == 070707); + g_assert(u.buf.c_magic == 070707); - name = g_malloc(buf.c_namesize); - if((len = mc_read(super->u.cpio.fd, name, buf.c_namesize)) < buf.c_namesize){ + if (u.buf.c_namesize == 0 || u.buf.c_namesize > MC_MAXPATHLEN) { + message (1, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name); + return STATUS_FAIL; + } + name = g_malloc(u.buf.c_namesize); + if((len = mc_read(super->u.cpio.fd, name, u.buf.c_namesize)) < u.buf.c_namesize){ g_free(name); return STATUS_EOF; } + name[u.buf.c_namesize - 1] = '\0'; CPIO_POS(super) += len; cpio_skip_padding(super); @@ -274,15 +288,15 @@ return STATUS_TRAIL; } - stat.st_dev = buf.c_dev; - stat.st_ino = buf.c_ino; - stat.st_mode = buf.c_mode; - stat.st_nlink = buf.c_nlink; - stat.st_uid = buf.c_uid; - stat.st_gid = buf.c_gid; - stat.st_rdev = buf.c_rdev; - stat.st_size = (buf.c_filesizes[0] << 16) | buf.c_filesizes[1]; - stat.st_atime = stat.st_mtime = stat.st_ctime = (buf.c_mtimes[0] << 16) | buf.c_mtimes[1]; + stat.st_dev = u.buf.c_dev; + stat.st_ino = u.buf.c_ino; + stat.st_mode = u.buf.c_mode; + stat.st_nlink = u.buf.c_nlink; + stat.st_uid = u.buf.c_uid; + stat.st_gid = u.buf.c_gid; + stat.st_rdev = u.buf.c_rdev; + stat.st_size = (u.buf.c_filesizes[0] << 16) | u.buf.c_filesizes[1]; + stat.st_atime = stat.st_mtime = stat.st_ctime = (u.buf.c_mtimes[0] << 16) | u.buf.c_mtimes[1]; return cpio_create_entry(me, super, &stat, name); } @@ -310,11 +324,16 @@ return STATUS_FAIL; } + if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN) { + message (1, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name); + return STATUS_FAIL; + } name = g_malloc(hd.c_namesize); if((len = mc_read(super->u.cpio.fd, name, hd.c_namesize)) < hd.c_namesize) { g_free (name); return STATUS_EOF; } + name[hd.c_namesize - 1] = '\0'; CPIO_POS(super) += len; cpio_skip_padding(super); @@ -365,11 +384,16 @@ (super->u.cpio.type == CPIO_CRC && hd.c_magic != 070702)) return STATUS_FAIL; + if (hd.c_namesize == 0 || hd.c_namesize > MC_MAXPATHLEN) { + message (1, MSG_ERROR, _("Corrupted cpio header encountered in\n%s"), super->name); + return STATUS_FAIL; + } name = g_malloc(hd.c_namesize); if((len = mc_read(super->u.cpio.fd, name, hd.c_namesize)) < hd.c_namesize){ g_free (name); return STATUS_EOF; } + name[hd.c_namesize - 1] = '\0'; CPIO_POS(super) += len; cpio_skip_padding(super); @@ -430,7 +454,8 @@ message_3s(1, MSG_ERROR, _("Inconsistent hardlinks of\n%s\nin cpio archive\n%s"), name, super->name); inode = NULL; - } + } else if (!inode->st.st_size) + inode->st.st_size = stat->st_size; } } diff -u -r --new-file mc-4.6.0.orig/vfs/direntry.c mc-4.6.0/vfs/direntry.c --- mc-4.6.0.orig/vfs/direntry.c 2002-12-25 18:21:43.000000000 -0800 +++ mc-4.6.0/vfs/direntry.c 2004-05-27 12:49:31.000000000 -0700 @@ -217,13 +217,11 @@ vfs_s_entry * vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path, int follow, int flags) { - unsigned int pseg; + size_t pseg; vfs_s_entry *ent = NULL; - char p[MC_MAXPATHLEN] = ""; + char p[MC_MAXPATHLEN] = "", *t = p; while (root){ - int t; - while (*path == PATH_SEP) /* Strip leading '/' */ path++; @@ -233,9 +231,14 @@ for (pseg = 0; path[pseg] && path[pseg] != PATH_SEP; pseg++) ; - strcat (p, PATH_SEP_STR); - strncpy (p + (t = strlen (p)), path, pseg); - p[t + pseg] = '\0'; + if (t + pseg + sizeof (PATH_SEP_STR) > p + sizeof (p)) + ERRNOR (ENOMEM, NULL); + + memcpy (t, PATH_SEP_STR, sizeof (PATH_SEP_STR) - 1); + t += sizeof (PATH_SEP_STR) - 1; + memcpy (t, path, pseg); + t += pseg; + *t = '\0'; for (ent = root->subdir; ent != NULL; ent = ent->next) if (strlen (ent->name) == pseg && (!strncmp (ent->name, path, pseg))) @@ -373,6 +376,7 @@ } } +#if 0 /* Convert absolute paths to relative ones */ if (*linkname == PATH_SEP) { char *p, *q; @@ -391,6 +395,7 @@ } linkname = buf; } +#endif return (MEDATA->find_entry) (me, entry->dir, linkname, follow - 1, 0); } @@ -622,8 +627,7 @@ return NULL; if (info->cur->name) { - strncpy(dir.dent.d_name, info->cur->name, MC_MAXPATHLEN); - dir.dent.d_name[MC_MAXPATHLEN] = 0; + g_strlcpy(dir.dent.d_name, info->cur->name, MC_MAXPATHLEN); } else { vfs_die("Null in structure-cannot happen"); } @@ -729,8 +733,7 @@ if (ino->linkname == NULL) ERRNOR (EFAULT, -1); - strncpy (buf, ino->linkname, size); - *(buf+size-1) = 0; + g_strlcpy (buf, ino->linkname, size); return strlen (buf); } @@ -1037,7 +1040,7 @@ struct vfs_s_inode *ino; char buf[MC_MAXPATHLEN]; - strncpy (buf, path, MC_MAXPATHLEN); + g_strlcpy (buf, path, MC_MAXPATHLEN); ino = vfs_s_inode_from_path (me, path, FL_FOLLOW | FL_NONE); if (!ino->localname) diff -u -r --new-file mc-4.6.0.orig/vfs/direntry.c~ mc-4.6.0/vfs/direntry.c~ --- mc-4.6.0.orig/vfs/direntry.c~ 1969-12-31 16:00:00.000000000 -0800 +++ mc-4.6.0/vfs/direntry.c~ 2004-05-27 12:48:06.000000000 -0700 @@ -0,0 +1,1202 @@ +/* Directory cache support -- so that you do not have copy of this in + * each and every filesystem. + * + * Written at 1998 by Pavel Machek , distribute under LGPL. + * + * Very loosely based on tar.c from midnight and archives.[ch] from + * avfs by Miklos Szeredi (mszeredi@inf.bme.hu) + * + * Unfortunately, I was unable to keep all filesystems + * uniform. tar-like filesystems use tree structure where each + * directory has pointers to its subdirectories. We can do this + * because we have full information about our archive. + * + * At ftp-like filesystems, situation is a little bit different. When + * you cd /usr/src/linux/drivers/char, you do _not_ want /usr, + * /usr/src, /usr/src/linux and /usr/src/linux/drivers to be + * listed. That means that we do not have complete information, and if + * /usr is symlink to /4, we will not know. Also we have to time out + * entries and things would get messy with tree-like approach. So we + * do different trick: root directory is completely special and + * completely fake, it contains entries such as 'usr', 'usr/src', ..., + * and we'll try to use custom find_entry function. + * + * Paths here do _not_ begin with '/', so root directory of + * archive/site is simply "". Beware. */ + +#include + +#include "utilvfs.h" +#include "xdirentry.h" +#include "../src/tty.h" + +#define CALL(x) if (MEDATA->x) MEDATA->x + +static volatile int total_inodes = 0, total_entries = 0; + +vfs_s_inode * +vfs_s_new_inode (vfs *me, vfs_s_super *super, struct stat *initstat) +{ + vfs_s_inode *ino; + + ino = g_new0 (vfs_s_inode, 1); + if (!ino) + return NULL; + + if (initstat) + ino->st = *initstat; + ino->super = super; + ino->st.st_nlink = 0; + ino->st.st_ino = MEDATA->inode_counter++; + ino->st.st_dev = MEDATA->rdev; + + super->ino_usage++; + total_inodes++; + + CALL (init_inode) (me, ino); + + return ino; +} + +vfs_s_entry * +vfs_s_new_entry (vfs *me, char *name, vfs_s_inode *inode) +{ + vfs_s_entry *entry; + + entry = g_new0 (struct vfs_s_entry, 1); + total_entries++; + + if (name) + entry->name = g_strdup (name); + + entry->ino = inode; + entry->ino->ent = entry; + CALL (init_entry) (me, entry); + + return entry; +} + +static void +vfs_s_free_inode (vfs *me, vfs_s_inode *ino) +{ + if (!ino) + vfs_die ("Don't pass NULL to me"); + + /* ==0 can happen if freshly created entry is deleted */ + if (ino->st.st_nlink <= 1){ + while (ino->subdir){ + vfs_s_free_entry (me, ino->subdir); + } + + CALL (free_inode) (me, ino); + g_free (ino->linkname); + if (ino->localname){ + unlink (ino->localname); + g_free(ino->localname); + } + total_inodes--; + ino->super->ino_usage--; + g_free(ino); + } else ino->st.st_nlink--; +} + +void +vfs_s_free_entry (vfs *me, vfs_s_entry *ent) +{ + int is_dot = 0; + if (ent->prevp){ /* It is possible that we are deleting freshly created entry */ + *ent->prevp = ent->next; + if (ent->next) + ent->next->prevp = ent->prevp; + } + + if (ent->name){ + is_dot = (!strcmp (ent->name, ".")) || (!strcmp (ent->name, "..")); + g_free (ent->name); + ent->name = NULL; + } + + if (!is_dot && ent->ino){ + ent->ino->ent = NULL; + vfs_s_free_inode (me, ent->ino); + ent->ino = NULL; + } + + total_entries--; + g_free(ent); +} + +void +vfs_s_insert_entry (vfs *me, vfs_s_inode *dir, vfs_s_entry *ent) +{ + vfs_s_entry **ep; + + for (ep = &dir->subdir; *ep != NULL; ep = &((*ep)->next)) + ; + ent->prevp = ep; + ent->next = NULL; + ent->dir = dir; + *ep = ent; + + ent->ino->st.st_nlink++; +} + +struct stat * +vfs_s_default_stat (vfs *me, mode_t mode) +{ + static struct stat st; + int myumask; + + myumask = umask (022); + umask (myumask); + mode &= ~myumask; + + st.st_mode = mode; + st.st_ino = 0; + st.st_dev = 0; + st.st_rdev = 0; + st.st_uid = getuid (); + st.st_gid = getgid (); + st.st_size = 0; + st.st_mtime = st.st_atime = st.st_ctime = time (NULL); + + return &st; +} + +void +vfs_s_add_dots (vfs *me, vfs_s_inode *dir, vfs_s_inode *parent) +{ + struct vfs_s_entry *dot, *dotdot; + + if (!parent) + parent = dir; + dot = vfs_s_new_entry (me, ".", dir); + dotdot = vfs_s_new_entry (me, "..", parent); + vfs_s_insert_entry (me, dir, dot); + vfs_s_insert_entry (me, dir, dotdot); + dir->st.st_nlink--; + parent->st.st_nlink--; /* We do not count "." and ".." into nlinks */ +} + +struct vfs_s_entry * +vfs_s_generate_entry (vfs *me, char *name, struct vfs_s_inode *parent, mode_t mode) +{ + struct vfs_s_inode *inode; + struct stat *st; + + st = vfs_s_default_stat (me, mode); + inode = vfs_s_new_inode (me, parent->super, st); + if (S_ISDIR (mode)) + vfs_s_add_dots (me, inode, parent); + + return vfs_s_new_entry (me, name, inode); +} + +/* We were asked to create entries automagically */ +vfs_s_entry * +vfs_s_automake (vfs *me, vfs_s_inode *dir, char *path, int flags) +{ + struct vfs_s_entry *res; + char *sep = strchr (path, PATH_SEP); + + if (sep) + *sep = 0; + res = vfs_s_generate_entry (me, path, dir, flags & FL_MKDIR ? (0777 | S_IFDIR) : 0777); + vfs_s_insert_entry (me, dir, res); + + if (sep) + *sep = PATH_SEP; + + return res; +} + +/* + * Follow > 0: follow links, serves as loop protect, + * == -1: do not follow links + */ +vfs_s_entry * +vfs_s_find_entry_tree (vfs *me, vfs_s_inode *root, char *path, int follow, int flags) +{ + unsigned int pseg; + vfs_s_entry *ent = NULL; + char p[MC_MAXPATHLEN] = ""; + + while (root){ + int t; + + while (*path == PATH_SEP) /* Strip leading '/' */ + path++; + + if (!path [0]) + return ent; + + for (pseg = 0; path[pseg] && path[pseg] != PATH_SEP; pseg++) + ; + + strcat (p, PATH_SEP_STR); + strncpy (p + (t = strlen (p)), path, pseg); + p[t + pseg] = '\0'; + + for (ent = root->subdir; ent != NULL; ent = ent->next) + if (strlen (ent->name) == pseg && (!strncmp (ent->name, path, pseg))) + /* FOUND! */ + break; + + if (!ent && (flags & (FL_MKFILE | FL_MKDIR))) + ent = vfs_s_automake (me, root, path, flags); + if (!ent) ERRNOR (ENOENT, NULL); + path += pseg; +/* here we must follow leading directories always; only the actual file is optional */ + if (!(ent = vfs_s_resolve_symlink (me, ent, p, strchr (path, PATH_SEP) ? LINK_FOLLOW : follow))) + return NULL; + root = ent->ino; + } + + return NULL; +} + +static void +split_dir_name (vfs *me, char *path, char **dir, char **name, char **save) +{ + char *s; + s = strrchr (path, PATH_SEP); + if (!s){ + *save = NULL; + *name = path; + *dir = ""; + } else { + *save = s; + *dir = path; + *s++ = 0; + *name = s; + } +} + +vfs_s_entry * +vfs_s_find_entry_linear (vfs *me, vfs_s_inode *root, char *path, int follow, int flags) +{ + vfs_s_entry* ent = NULL; + + if (root->super->root != root) + vfs_die ("We have to use _real_ root. Always. Sorry." ); + + canonicalize_pathname (path); + + if (!(flags & FL_DIR)){ + char *dirname, *name, *save; + vfs_s_inode *ino; + split_dir_name (me, path, &dirname, &name, &save); + ino = vfs_s_find_inode (me, root, dirname, follow, flags | FL_DIR); + if (save) + *save = PATH_SEP; + return vfs_s_find_entry_tree (me, ino, name, follow, flags); + } + + for (ent = root->subdir; ent != NULL; ent = ent->next) + if (!strcmp (ent->name, path)) + break; + + if (ent && (! (MEDATA->dir_uptodate) (me, ent->ino))){ +#if 1 + print_vfs_message (_("Directory cache expired for %s"), path); +#endif + vfs_s_free_entry (me, ent); + ent = NULL; + } + + if (!ent){ + vfs_s_inode *ino; + + ino = vfs_s_new_inode (me, root->super, vfs_s_default_stat (me, S_IFDIR | 0755)); + ent = vfs_s_new_entry (me, path, ino); + if ((MEDATA->dir_load) (me, ino, path) == -1){ + vfs_s_free_entry (me, ent); + return NULL; + } + vfs_s_insert_entry (me, root, ent); + + for (ent = root->subdir; ent != NULL; ent = ent->next) + if (!strcmp (ent->name, path)) + break; + } + if (!ent) + vfs_die ("find_linear: success but directory is not there\n"); + +#if 0 + if (!vfs_s_resolve_symlink (me, ent, follow)) return NULL; +#endif + return ent; +} + +vfs_s_inode * +vfs_s_find_inode (vfs *me, vfs_s_inode *root, char *path, int follow, int flags) +{ + vfs_s_entry *ent; + if ((MEDATA->find_entry == vfs_s_find_entry_tree) && (!*path)) + return root; + ent = (MEDATA->find_entry)(me, root, path, follow, flags); + if (!ent) + return NULL; + return ent->ino; +} + +vfs_s_entry * +vfs_s_resolve_symlink (vfs *me, vfs_s_entry *entry, char *path, int follow) +{ + char buf[MC_MAXPATHLEN], *linkname; + + if (follow == LINK_NO_FOLLOW) + return entry; + if (follow == 0) + ERRNOR (ELOOP, NULL); + if (!entry) + ERRNOR (ENOENT, NULL); + if (!S_ISLNK (entry->ino->st.st_mode)) + return entry; + + linkname = entry->ino->linkname; + + if (linkname == NULL) + ERRNOR (EFAULT, NULL); + + if (MEDATA->find_entry == vfs_s_find_entry_linear) { + if (*linkname == PATH_SEP) + return (MEDATA->find_entry) (me, entry->dir->super->root, + linkname, follow - 1, 0); + else { + char *fullpath = vfs_s_fullpath (me, entry->dir); + + g_snprintf (buf, sizeof (buf), "%s/%s", fullpath, linkname); + g_free (fullpath); + return (MEDATA->find_entry) (me, entry->dir->super->root, buf, + follow - 1, 0); + } + } + +#if 0 + /* Convert absolute paths to relative ones */ + if (*linkname == PATH_SEP) { + char *p, *q; + + for (p = path, q = entry->ino->linkname; *p == *q; p++, q++); + while (*(--q) != PATH_SEP); + q++; + for (;; p++) { + p = strchr (p, PATH_SEP); + if (!p) { + strcat (buf, q); + break; + } + strcat (buf, ".."); + strcat (buf, PATH_SEP_STR); + } + linkname = buf; + } +#endif + + return (MEDATA->find_entry) (me, entry->dir, linkname, follow - 1, 0); +} + +/* Ook, these were functions around directory entries / inodes */ +/* -------------------------------- superblock games -------------------------- */ + +vfs_s_super * +vfs_s_new_super (vfs *me) +{ + vfs_s_super *super; + + super = g_new0 (struct vfs_s_super, 1); + super->me = me; + return super; +} + +static void +vfs_s_insert_super (vfs *me, vfs_s_super *super) +{ + super->next = MEDATA->supers; + super->prevp = &MEDATA->supers; + + if (MEDATA->supers != NULL) + MEDATA->supers->prevp = &super->next; + MEDATA->supers = super; +} + +void +vfs_s_free_super (vfs *me, vfs_s_super *super) +{ + if (super->root){ + vfs_s_free_inode (me, super->root); + super->root = NULL; + } + +#if 0 + /* FIXME: We currently leak small ammount of memory, sometimes. Fix it if you can. */ + if (super->ino_usage) + message_1s1d (1, " Direntry warning ", + "Super ino_usage is %d, memory leak", + super->ino_usage); + + if (super->want_stale) + message_1s (1, " Direntry warning ", "Super has want_stale set"); +#endif + + if (super->prevp){ + *super->prevp = super->next; + if (super->next) + super->next->prevp = super->prevp; + } + + CALL (free_archive) (me, super); + g_free (super->name); + super->name = NULL; + g_free(super); +} + +/* ------------------------------------------------------------------------= */ + +static void +vfs_s_stamp_me (vfs *me, struct vfs_s_super *psup, char *fs_name) +{ + struct vfs_stamping *parent; + vfs *v; + + v = vfs_type (fs_name); + if (v == &vfs_local_ops){ + parent = NULL; + } else { + parent = g_new (struct vfs_stamping, 1); + parent->v = v; + parent->next = 0; + parent->id = (*v->getid) (v, fs_name, &(parent->parent)); + } + vfs_add_noncurrent_stamps (me, (vfsid) psup, parent); + vfs_rm_parents (parent); +} + +char * +vfs_s_get_path_mangle (vfs *me, char *inname, struct vfs_s_super **archive, int flags) +{ + char *local, *op, *archive_name; + int result = -1; + struct vfs_s_super *super; + void *cookie = NULL; + + archive_name = inname; + vfs_split (inname, &local, &op); + if (!local) + local = ""; + + if (MEDATA->archive_check) + if (! (cookie = MEDATA->archive_check (me, archive_name, op))) + return NULL; + + for (super = MEDATA->supers; super != NULL; super = super->next){ + int i; /* 0 == other, 1 == same, return it, 2 == other but stop scanning */ + if ((i = MEDATA->archive_same (me, super, archive_name, op, cookie))){ + if (i==1) goto return_success; + else break; + } + } + + if (flags & FL_NO_OPEN) + ERRNOR (EIO, NULL); + + super = vfs_s_new_super (me); + result = MEDATA->open_archive (me, super, archive_name, op); + if (result == -1){ + vfs_s_free_super (me, super); + ERRNOR (EIO, NULL); + } + if (!super->name) + vfs_die ("You have to fill name\n"); + if (!super->root) + vfs_die ("You have to fill root inode\n"); + + vfs_s_insert_super (me, super); + vfs_s_stamp_me (me, super, archive_name); + +return_success: + *archive = super; + return local; +} + +char * +vfs_s_get_path (vfs *me, char *inname, struct vfs_s_super **archive, int flags) +{ + char *buf = g_strdup( inname ); + char *res = vfs_s_get_path_mangle (me, buf, archive, flags); + if (res) + res = g_strdup(res); + g_free(buf); + return res; +} + +void +vfs_s_invalidate (vfs *me, vfs_s_super *super) +{ + if (!super->want_stale){ + vfs_s_free_inode (me, super->root); + super->root = vfs_s_new_inode (me, super, vfs_s_default_stat (me, S_IFDIR | 0755)); + } +} + +char * +vfs_s_fullpath (vfs *me, vfs_s_inode *ino) +{ +/* For now, usable only on filesystems with _linear structure */ + if (MEDATA->find_entry != vfs_s_find_entry_linear) + vfs_die ("Implement me!"); + if (!ino->ent) /* That must be directory... */ + ERRNOR (EAGAIN, NULL); + + if ((!ino->ent->dir) || (!ino->ent->dir->ent)) /* It must be directory */ + return g_strdup (ino->ent->name); + + return g_strconcat (ino->ent->dir->ent->name, PATH_SEP_STR, + ino->ent->name, NULL); +} + +/* Support of archives */ +/* ------------------------ readdir & friends ----------------------------- */ + +vfs_s_super *vfs_s_super_from_path (vfs *me, char *name) +{ + struct vfs_s_super *super; + + if (!vfs_s_get_path_mangle (me, name, &super, 0)) + return NULL; + return super; +} + +vfs_s_inode * +vfs_s_inode_from_path (vfs *me, char *name, int flags) +{ + struct vfs_s_super *super; + struct vfs_s_inode *ino; + char *q; + + if (!(q = vfs_s_get_path_mangle (me, name, &super, 0))) + return NULL; + + ino = vfs_s_find_inode (me, super->root, q, flags & FL_FOLLOW ? LINK_FOLLOW : LINK_NO_FOLLOW, flags & ~FL_FOLLOW); + if ((!ino) && (!*q)) + /* We are asking about / directory of ftp server: assume it exists */ + ino = vfs_s_find_inode (me, super->root, q, flags & FL_FOLLOW ? LINK_FOLLOW : LINK_NO_FOLLOW, FL_DIR | (flags & ~FL_FOLLOW)); + return ino; +} + +struct dirhandle { + vfs_s_entry *cur; + vfs_s_inode *dir; +}; + +void * +vfs_s_opendir (vfs *me, char *dirname) +{ + struct vfs_s_inode *dir; + struct dirhandle *info; + + dir = vfs_s_inode_from_path (me, dirname, FL_DIR | FL_FOLLOW); + if (!dir) + return NULL; + if (!S_ISDIR (dir->st.st_mode)) + ERRNOR (ENOTDIR, NULL); + + dir->st.st_nlink++; +#if 0 + if (!dir->subdir) /* This can actually happen if we allow empty directories */ + ERRNOR (EAGAIN, NULL); +#endif + info = g_new (struct dirhandle, 1); + info->cur = dir->subdir; + info->dir = dir; + + return info; +} + +void * +vfs_s_readdir(void *data) +{ + static union vfs_dirent dir; + struct dirhandle *info = (struct dirhandle *) data; + + if (!(info->cur)) + return NULL; + + if (info->cur->name) { + strncpy(dir.dent.d_name, info->cur->name, MC_MAXPATHLEN); + dir.dent.d_name[MC_MAXPATHLEN] = 0; + } else { + vfs_die("Null in structure-cannot happen"); + } + + compute_namelen(&dir.dent); + info->cur = info->cur->next; + + return (void *) &dir; +} + +int +vfs_s_telldir (void *data) +{ + struct dirhandle *info = (struct dirhandle *) data; + struct vfs_s_entry *cur; + int num = 0; + + cur = info->dir->subdir; + while (cur!=NULL){ + if (cur == info->cur) + return num; + num++; + cur = cur->next; + } + return -1; +} + +void +vfs_s_seekdir (void *data, int offset) +{ + struct dirhandle *info = (struct dirhandle *) data; + int i; + info->cur = info->dir->subdir; + for (i=0; idir; + + vfs_s_free_inode (dir->super->me, dir); + g_free (data); + return 0; +} + +int +vfs_s_chdir (vfs *me, char *path) +{ + void *data; + if (!(data = vfs_s_opendir (me, path))) + return -1; + vfs_s_closedir (data); + return 0; +} + +/* --------------------------- stat and friends ---------------------------- */ + +static int +vfs_s_internal_stat (vfs *me, char *path, struct stat *buf, int flag) +{ + struct vfs_s_inode *ino; + + if (!(ino = vfs_s_inode_from_path (me, path, flag))) + return -1; + *buf = ino->st; + return 0; +} + +int +vfs_s_stat (vfs *me, char *path, struct stat *buf) +{ + return vfs_s_internal_stat (me, path, buf, FL_FOLLOW); +} + +int +vfs_s_lstat (vfs *me, char *path, struct stat *buf) +{ + return vfs_s_internal_stat (me, path, buf, FL_NONE); +} + +int +vfs_s_fstat (void *fh, struct stat *buf) +{ + *buf = FH->ino->st; + return 0; +} + +int +vfs_s_readlink (vfs *me, char *path, char *buf, int size) +{ + struct vfs_s_inode *ino; + + ino = vfs_s_inode_from_path (me, path, 0); + if (!ino) + return -1; + + if (!S_ISLNK (ino->st.st_mode)) + ERRNOR (EINVAL, -1); + + if (ino->linkname == NULL) + ERRNOR (EFAULT, -1); + + strncpy (buf, ino->linkname, size); + *(buf+size-1) = 0; + return strlen (buf); +} + +void * +vfs_s_open (vfs *me, char *file, int flags, int mode) +{ + int was_changed = 0; + struct vfs_s_fh *fh; + vfs_s_super *super; + char *q; + struct vfs_s_inode *ino; + + if ((q = vfs_s_get_path_mangle (me, file, &super, 0)) == NULL) + return NULL; + ino = vfs_s_find_inode (me, super->root, q, LINK_FOLLOW, FL_NONE); + if (ino && ((flags & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))) + ERRNOR (EEXIST, NULL); + if (!ino){ + char *dirname, *name, *save; + vfs_s_entry *ent; + vfs_s_inode *dir; + int tmp_handle; + + /* If the filesystem is read-only, disable file creation */ + if (!(flags & O_CREAT) || !(me->write)) + return NULL; + + split_dir_name (me, q, &dirname, &name, &save); +/* FIXME: if vfs_s_find_inode returns NULL, this will do rather bad + things. */ + dir = vfs_s_find_inode (me, super->root, dirname, LINK_FOLLOW, FL_DIR); + if (save) + *save = PATH_SEP; + ent = vfs_s_generate_entry (me, name, dir, 0755); + ino = ent->ino; + vfs_s_insert_entry (me, dir, ent); + tmp_handle = mc_mkstemps (&ino->localname, me->name, NULL); + if (tmp_handle == -1) + return NULL; + close (tmp_handle); + was_changed = 1; + } + + if (S_ISDIR (ino->st.st_mode)) + ERRNOR (EISDIR, NULL); + + fh = g_new (struct vfs_s_fh, 1); + fh->pos = 0; + fh->ino = ino; + fh->handle = -1; + fh->changed = was_changed; + fh->linear = 0; + + if (IS_LINEAR(flags)) { + if (MEDATA->linear_start) { + print_vfs_message (_("Starting linear transfer...")); + if (!MEDATA->linear_start (me, fh, 0)){ + g_free(fh); + return NULL; + } + } + } else if ((MEDATA->fh_open) && (MEDATA->fh_open (me, fh, flags, mode))){ + g_free(fh); + return NULL; + } + + if (fh->ino->localname){ + fh->handle = open (fh->ino->localname, NO_LINEAR(flags), mode); + if (fh->handle == -1){ + g_free(fh); + ERRNOR (errno, NULL); + } + } + + /* i.e. we had no open files and now we have one */ + vfs_rmstamp (me, (vfsid) super, 1); + super->fd_usage++; + fh->ino->st.st_nlink++; + return fh; +} + +int +vfs_s_read (void *fh, char *buffer, int count) +{ + int n; + vfs *me = FH_SUPER->me; + + if (FH->linear == LS_LINEAR_CLOSED) + vfs_die ("linear_start() did not set linear_state!"); + + if (FH->linear == LS_LINEAR_OPEN) + return MEDATA->linear_read (me, FH, buffer, count); + + if (FH->handle != -1){ + n = read (FH->handle, buffer, count); + if (n < 0) + me->verrno = errno; + return n; + } + vfs_die ("vfs_s_read: This should not happen\n"); + return -1; +} + +int +vfs_s_write (void *fh, char *buffer, int count) +{ + int n; + vfs *me = FH_SUPER->me; + + if (FH->linear) + vfs_die ("no writing to linear files, please"); + + FH->changed = 1; + if (FH->handle != -1){ + n = write (FH->handle, buffer, count); + if (n < 0) + me->verrno = errno; + return n; + } + vfs_die ("vfs_s_write: This should not happen\n"); + return 0; +} + +int +vfs_s_lseek (void *fh, off_t offset, int whence) +{ + off_t size = FH->ino->st.st_size; + + if (FH->handle != -1){ /* If we have local file opened, we want to work with it */ + int retval = lseek (FH->handle, offset, whence); + if (retval == -1) + FH->ino->super->me->verrno = errno; + return retval; + } + + switch (whence){ + case SEEK_CUR: + offset += FH->pos; break; + case SEEK_END: + offset += size; break; + } + if (offset < 0) + FH->pos = 0; + else if (offset < size) + FH->pos = offset; + else + FH->pos = size; + return FH->pos; +} + +int +vfs_s_close (void *fh) +{ + int res = 0; + vfs *me = FH_SUPER->me; + + FH_SUPER->fd_usage--; + if (!FH_SUPER->fd_usage){ + struct vfs_stamping *parent; + vfs *v; + + v = vfs_type (FH_SUPER->name); + if (v == &vfs_local_ops){ + parent = NULL; + } else { + parent = g_new (struct vfs_stamping, 1); + parent->v = v; + parent->next = 0; + parent->id = (*v->getid) (v, FH_SUPER->name, &(parent->parent)); + } + vfs_add_noncurrent_stamps (me, (vfsid) (FH_SUPER), parent); + vfs_rm_parents (parent); + } + if (FH->linear == LS_LINEAR_OPEN) + MEDATA->linear_close (me, fh); + if (MEDATA->fh_close) + res = MEDATA->fh_close (me, fh); + if (FH->changed && MEDATA->file_store){ + char *s = vfs_s_fullpath (me, FH->ino); + if (!s) + res = -1; + else { + res = MEDATA->file_store (me, fh, s, FH->ino->localname); + g_free (s); + } + vfs_s_invalidate (me, FH_SUPER); + } + if (FH->handle != -1) + close (FH->handle); + + vfs_s_free_inode (me, FH->ino); + g_free (fh); + return res; +} + +int +vfs_s_retrieve_file (vfs *me, struct vfs_s_inode *ino) +{ + /* If you want reget, you'll have to open file with O_LINEAR */ + off_t total = 0; + char buffer[8192]; + int handle, n; + off_t stat_size = ino->st.st_size; + struct vfs_s_fh fh; + + memset (&fh, 0, sizeof (fh)); + + fh.ino = ino; + fh.handle = -1; + + handle = mc_mkstemps (&ino->localname, me->name, NULL); + if (handle == -1) { + me->verrno = errno; + goto error_4; + } + + if (!MEDATA->linear_start (me, &fh, 0)) + goto error_3; + + /* Clear the interrupt status */ + got_interrupt (); + enable_interrupt_key (); + + while ((n = MEDATA->linear_read (me, &fh, buffer, sizeof (buffer)))) { + + if (n < 0) + goto error_1; + + total += n; + vfs_print_stats (me->name, _("Getting file"), ino->ent->name, + total, stat_size); + + if (got_interrupt ()) + goto error_1; + + if (write (handle, buffer, n) < 0) { + me->verrno = errno; + goto error_1; + } + } + MEDATA->linear_close (me, &fh); + close (handle); + + disable_interrupt_key (); + return 0; + + error_1: + MEDATA->linear_close (me, &fh); + error_3: + disable_interrupt_key (); + close (handle); + unlink (ino->localname); + error_4: + g_free (ino->localname); + ino->localname = NULL; + return -1; +} + +/* ------------------------------- mc support ---------------------------- */ + +void +vfs_s_fill_names (vfs *me, void (*func)(char *)) +{ + struct vfs_s_super *a = MEDATA->supers; + char *name; + + while (a){ + name = g_strconcat ( a->name, "#", me->prefix, "/", /* a->current_dir->name, */ NULL); + (*func)(name); + g_free (name); + a = a->next; + } +} + +int +vfs_s_ferrno (vfs *me) +{ + return me->verrno; +} + +void +vfs_s_dump (vfs *me, char *prefix, vfs_s_inode *ino) +{ + printf ("%s %s %d ", prefix, S_ISDIR (ino->st.st_mode) ? "DIR" : "FILE", ino->st.st_mode); + if (!ino->subdir) + printf ("FILE\n"); + else + { + struct vfs_s_entry *ent; + for (ent = ino->subdir; ent ; ent = ent->next){ + char *s = g_strconcat (prefix, "/", ent->name, NULL); + if (ent->name[0] == '.') + printf ("%s IGNORED\n", s); + else + vfs_s_dump (me, s, ent->ino); + g_free(s); + } + } +} + +char * +vfs_s_getlocalcopy (vfs *me, char *path) +{ + struct vfs_s_inode *ino; + char buf[MC_MAXPATHLEN]; + + strncpy (buf, path, MC_MAXPATHLEN); + ino = vfs_s_inode_from_path (me, path, FL_FOLLOW | FL_NONE); + + if (!ino->localname) + ino->localname = mc_def_getlocalcopy (me, buf); + /* FIXME: fd_usage++ missing */ + return g_strdup (ino->localname); +} + +int +vfs_s_setctl (vfs *me, char *path, int ctlop, char *arg) +{ + vfs_s_inode *ino = vfs_s_inode_from_path (me, path, 0); + if (!ino) + return 0; + switch (ctlop){ + case MCCTL_WANT_STALE_DATA: + ino->super->want_stale = 1; + return 1; + case MCCTL_NO_STALE_DATA: + ino->super->want_stale = 0; + vfs_s_invalidate(me, ino->super); + return 1; +#if 0 /* FIXME: We should implement these */ + case MCCTL_REMOVELOCALCOPY: + return remove_temp_file (path); + case MCCTL_FORGET_ABOUT: + my_forget(path); + return 0; +#endif + } + return 0; +} + + +/* ----------------------------- Stamping support -------------------------- */ + +vfsid +vfs_s_getid (vfs *me, char *path, struct vfs_stamping **parent) +{ + vfs_s_super *archive; + vfs *v; + char *p; + vfsid id; + struct vfs_stamping *par; + + *parent = NULL; + if (!(p = vfs_s_get_path (me, path, &archive, FL_NO_OPEN))) + return (vfsid) -1; + g_free(p); + v = vfs_type (archive->name); + id = (*v->getid) (v, archive->name, &par); + if (id != (vfsid)-1){ + *parent = g_new (struct vfs_stamping, 1); + (*parent)->v = v; + (*parent)->id = id; + (*parent)->parent = par; + (*parent)->next = NULL; + } + return (vfsid) archive; +} + +int +vfs_s_nothingisopen (vfsid id) +{ + /* Our data structures should survive free of superblock at any time */ + return 1; +} + +void +vfs_s_free (vfsid id) +{ + vfs_s_free_super (((vfs_s_super *)id)->me, (vfs_s_super *)id); +} + +/* ----------- Utility functions for networked filesystems -------------- */ + +#ifdef USE_NETCODE +int +vfs_s_select_on_two (int fd1, int fd2) +{ + fd_set set; + struct timeval timeout; + int v; + int maxfd = (fd1 > fd2 ? fd1 : fd2) + 1; + + timeout.tv_sec = 1; + timeout.tv_usec = 0; + FD_ZERO (&set); + FD_SET (fd1, &set); + FD_SET (fd2, &set); + v = select (maxfd, &set, 0, 0, &timeout); + if (v <= 0) + return v; + if (FD_ISSET (fd1, &set)) + return 1; + if (FD_ISSET (fd2, &set)) + return 2; + return -1; +} + +int +vfs_s_get_line (vfs *me, int sock, char *buf, int buf_len, char term) +{ + FILE *logfile = MEDATA->logfile; + int i, status; + char c; + + for (i = 0; i < buf_len - 1; i++, buf++){ + if (read (sock, buf, sizeof(char)) <= 0) + return 0; + if (logfile){ + fwrite (buf, 1, 1, logfile); + fflush (logfile); + } + if (*buf == term){ + *buf = 0; + return 1; + } + } + + /* Line is too long - terminate buffer and discard the rest of line */ + *buf = 0; + while ((status = read (sock, &c, sizeof (c))) > 0){ + if (logfile){ + fwrite (&c, 1, 1, logfile); + fflush (logfile); + } + if (c == '\n') + return 1; + } + return 0; +} + +int +vfs_s_get_line_interruptible (vfs *me, char *buffer, int size, int fd) +{ + int n; + int i; + + enable_interrupt_key (); + for (i = 0; i < size-1; i++){ + n = read (fd, buffer+i, 1); + disable_interrupt_key (); + if (n == -1 && errno == EINTR){ + buffer [i] = 0; + return EINTR; + } + if (n == 0){ + buffer [i] = 0; + return 0; + } + if (buffer [i] == '\n'){ + buffer [i] = 0; + return 1; + } + } + buffer [size-1] = 0; + return 0; +} +#endif /* USE_NETCODE */ diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/deb.in mc-4.6.0/vfs/extfs/deb.in --- mc-4.6.0.orig/vfs/extfs/deb.in 2002-12-11 12:57:00.000000000 -0800 +++ mc-4.6.0/vfs/extfs/deb.in 2004-05-27 12:49:30.000000000 -0700 @@ -149,15 +149,10 @@ } else { - $suffix = "aaa"; - while (1) { - $tmpdir = "/tmp/mcdebfs.run".$$.$suffix; - last if mkdir $tmpdir, 0700; - $suffix++; - # Somebody is being really nasty, give up - exit 1 if $suffix eq "zzz"; - } - + use File::Temp qw(mkdtemp); + my $template = "/tmp/mcdebfs.run.XXXXXX"; + $template="$ENV{MC_TMPDIR}/mcdebfs.XXXXXX" if ($ENV{MC_TMPDIR}); + $tmpdir = mkdtemp($template); $tmpcmd="$tmpdir/run"; &mcdebfs_copyout($archive, $filename, $tmpcmd); system("chmod u+x $tmpcmd"); diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/rpm mc-4.6.0/vfs/extfs/rpm --- mc-4.6.0.orig/vfs/extfs/rpm 2002-12-29 01:19:39.000000000 -0800 +++ mc-4.6.0/vfs/extfs/rpm 2004-05-27 12:49:30.000000000 -0700 @@ -1,14 +1,17 @@ #! /bin/sh # # Written by Erik Troan (ewt@redhat.com) 1996 -# Jakub Jelinek (jj@sunsite.mff.cuni.cz) 1996 +# Jakub Jelinek (jj@sunsite.mff.cuni.cz) 1996, 2004 # Tomasz Koczko (kloczek@rudy.mif.pg.gda.pl) 1997 # minor changes by Wojtek Pilorz (wpilorz@bdk.lublin.pl) 1997 # minor changes by Michele Marziani (marziani@fe.infn.it) 1997 # bug files by Marc Merlin (marcsoft@merlins.org) 1998 # locale bugfix by Michal Svec (rebel@penguin.cz) 2000 -# (C) 1996 The Free Software Foundation. +# Whitespace(s) & single quote(s) in filename workaround +# by Andrew V. Samoilov 2004 +# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=64007 # +# (C) 1996-2004 The Free Software Foundation. # # override any locale for dates @@ -22,6 +25,10 @@ RPM="rpm" fi RPM2CPIO="rpm2cpio" +SED=sed +# Surround the whole filename with single quotes and handle specially +# \', ' and \ at the end of the string. +SEDCMD="s/\\(\\\\\\?\\)'/'\\1\\1\\\\''/g;s/\\\\\$/'\\\\\\\\'/;s/^/'/;s/\$/'/" mcrpmfs_list () { @@ -31,12 +38,13 @@ if test -z "$MCFASTRPM"; then MCFASTRPM=$MCFASTRPM_DFLT fi + f="`echo "$1" | $SED "$SEDCMD"`" FILEPREF="-r--r--r-- 1 root root " - DESC=`$RPM -qip "$1" 2>/dev/null` || { + DESC=`$RPM -qip "$f" 2>/dev/null` || { echo "$FILEPREF 0 "`date +"%b %d %H:%M"`" ERROR" exit 1 } - DATE=`$RPM -qp --qf "%{BUILDTIME:date}\n" "$1" | cut -c 5-11,21-24` + DATE=`$RPM -qp --qf "%{BUILDTIME:date}\n" "$f" | cut -c 5-11,21-24` HEADERSIZE=`echo "$DESC" | wc -c` echo "-r--r--r-- 1 root root $HEADERSIZE $DATE HEADER" echo "-r-xr-xr-x 1 root root 39 $DATE INSTALL" @@ -47,25 +55,25 @@ echo "$FILEPREF 0 $DATE INFO/BUILDHOST" echo "$FILEPREF 0 $DATE INFO/SOURCERPM" if test "$MCFASTRPM" = 0 ; then - test "`$RPM -qp --qf \"%{DISTRIBUTION}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{DISTRIBUTION}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/DISTRIBUTION" - test "`$RPM -qp --qf \"%{VENDOR}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{VENDOR}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/VENDOR" - test "`$RPM -qp --qf \"%{DESCRIPTION}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{DESCRIPTION}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/DESCRIPTION" - test "`$RPM -qp --qf \"%{SUMMARY}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{SUMMARY}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/SUMMARY" - if test "`$RPM -qp --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" \"$1\"`" != "(none)(none)(none)(none)(none)"; then + if test "`$RPM -qp --qf \"%{RPMTAG_PREIN}%{RPMTAG_POSTIN}%{RPMTAG_PREUN}%{RPMTAG_POSTUN}%{VERIFYSCRIPT}\" \"$f\"`" != "(none)(none)(none)(none)(none)"; then echo "dr-xr-xr-x 1 root root 0 $DATE INFO/SCRIPTS" - test "`$RPM -qp --qf \"%{RPMTAG_PREIN}\" \"$1\"`" = '(none)' || + test "`$RPM -qp --qf \"%{RPMTAG_PREIN}\" \"$f\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREIN" - test "`$RPM -qp --qf \"%{RPMTAG_POSTIN}\" \"$1\"`" = '(none)' || + test "`$RPM -qp --qf \"%{RPMTAG_POSTIN}\" \"$f\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTIN" - test "`$RPM -qp --qf \"%{RPMTAG_PREUN}\" \"$1\"`" = '(none)' || + test "`$RPM -qp --qf \"%{RPMTAG_PREUN}\" \"$f\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/PREUN" - test "`$RPM -qp --qf \"%{RPMTAG_POSTUN}\" \"$1\"`" = '(none)' || + test "`$RPM -qp --qf \"%{RPMTAG_POSTUN}\" \"$f\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/POSTUN" - test "`$RPM -qp --qf \"%{VERIFYSCRIPT}\" \"$1\"`" = '(none)' || + test "`$RPM -qp --qf \"%{VERIFYSCRIPT}\" \"$f\"`" = '(none)' || echo "$FILEPREF 0 $DATE INFO/SCRIPTS/VERIFYSCRIPT" echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" fi @@ -83,15 +91,15 @@ echo "$FILEPREF 0 $DATE INFO/SCRIPTS/ALL" fi if test "$MCFASTRPM" = 0 ; then - test "`$RPM -qp --qf \"%{PACKAGER}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{PACKAGER}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/PACKAGER" - test "`$RPM -qp --qf \"%{URL}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{URL}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/URL" - test "`$RPM -qp --qf \"%{SERIAL}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{SERIAL}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/SERIAL" - test "`$RPM -qp --qf \"%{COPYRIGHT}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{COPYRIGHT}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/COPYRIGHT" - test "`$RPM -qp --qf \"%{LICENSE}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{LICENSE}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/LICENSE" else echo "$FILEPREF 0 $DATE INFO/PACKAGER" @@ -105,13 +113,13 @@ echo "$FILEPREF 0 $DATE INFO/OS" echo "$FILEPREF 0 $DATE INFO/SIZE" if test "$MCFASTRPM" != 0 ; then - $RPM -qp --qf "[%{REQUIRENAME}\n]" "$1" | grep "(none)" > /dev/null || + $RPM -qp --qf "[%{REQUIRENAME}\n]" "$f" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" - $RPM -qp --qf "[%{OBSOLETES}\n]" "$1" | grep "(none)" > /dev/null || + $RPM -qp --qf "[%{OBSOLETES}\n]" "$f" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/OBSOLETES" - $RPM -qp --qf "[%{PROVIDES}\n]" "$1" | grep "(none)" > /dev/null || + $RPM -qp --qf "[%{PROVIDES}\n]" "$f" | grep "(none)" > /dev/null || echo "$FILEPREF 0 $DATE INFO/PROVIDES" - test "`$RPM -qp --qf \"%{CHANGELOGTEXT}\" \"$1\"`" = "(none)" || + test "`$RPM -qp --qf \"%{CHANGELOGTEXT}\" \"$f\"`" = "(none)" || echo "$FILEPREF 0 $DATE INFO/CHANGELOG" else echo "$FILEPREF 0 $DATE INFO/REQUIRENAME" @@ -126,41 +134,41 @@ mcrpmfs_copyout () { + f="`echo "$1" | $SED "$SEDCMD"`" case "$2" in - HEADER) $RPM -qip "$1" > "$3"; exit 0;; - INSTALL) echo "# Run this to install this RPM package" > "$3"; exit 0;; - UPGRADE) echo "# Run this to upgrade this RPM package" > "$3"; exit 0;; - ERROR) $RPM -qip "$1" > /dev/null 2> "$3"; exit 0;; - INFO/NAME-VERSION-RELEASE) $RPM -qp --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" "$1" > "$3"; exit 0;; - INFO/RELEASE) $RPM -qp --qf "%{RELEASE}\n" "$1" > "$3"; exit 0;; - INFO/GROUP) $RPM -qp --qf "%{GROUP}\n" "$1" > "$3"; exit 0;; - INFO/DISTRIBUTION) $RPM -qp --qf "%{DISTRIBUTION}\n" "$1" > "$3"; exit 0;; - INFO/VENDOR) $RPM -qp --qf "%{VENDOR}\n" "$1" > "$3"; exit 0;; - INFO/BUILDHOST) $RPM -qp --qf "%{BUILDHOST}\n" "$1" > "$3"; exit 0;; - INFO/SOURCERPM) $RPM -qp --qf "%{SOURCERPM}\n" "$1" > "$3"; exit 0;; - INFO/DESCRIPTION) $RPM -qp --qf "%{DESCRIPTION}\n" "$1" > "$3"; exit 0;; - INFO/PACKAGER) $RPM -qp --qf "%{PACKAGER}\n" "$1" > "$3"; exit 0;; - INFO/URL) $RPM -qp --qf "%{URL}\n" "$1" >"$3"; exit 0;; - INFO/BUILDTIME) $RPM -qp --qf "%{BUILDTIME:date}\n" "$1" >"$3"; exit 0;; - INFO/SERIAL) $RPM -qp --qf "%{SERIAL}\n" "$1" >"$3"; exit 0;; - INFO/COPYRIGHT) $RPM -qp --qf "%{COPYRIGHT}\n" "$1" >"$3"; exit 0;; - INFO/RPMVERSION) $RPM -qp --qf "%{RPMVERSION}\n" "$1" >"$3"; exit 0;; - INFO/REQUIRENAME) $RPM -qp --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" "$1" >"$3"; exit 0;; - INFO/PROVIDES) $RPM -qp --qf "[%{PROVIDES}\n]" "$1" >"$3"; exit 0;; - INFO/SCRIPTS/PREIN) $RPM -qp --qf "%{RPMTAG_PREIN}\n" "$1" >"$3"; exit 0;; - INFO/SCRIPTS/POSTIN) $RPM -qp --qf "%{RPMTAG_POSTIN}\n" "$1" >"$3"; exit 0;; - INFO/SCRIPTS/PREUN) $RPM -qp --qf "%{RPMTAG_PREUN}\n" "$1" >"$3"; exit 0;; - INFO/SCRIPTS/POSTUN) $RPM -qp --qf "%{RPMTAG_POSTUN}\n" "$1" >"$3"; exit 0;; - INFO/SCRIPTS/VERIFYSCRIPT) $RPM -qp --qf "%{VERIFYSCRIPT}\n" "$1" >"$3"; exit 0;; - INFO/SCRIPTS/ALL) $RPM -qp --scripts "$1" > "$3"; exit 0;; - INFO/SUMMARY) $RPM -qp --qf "%{SUMMARY}\n" "$1" > "$3"; exit 0;; - INFO/OS) $RPM -qp --qf "%{OS}\n" "$1" > "$3"; exit 0;; - INFO/CHANGELOG) $RPM -qp --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" "$1" > "$3"; exit 0;; - INFO/SIZE) $RPM -qp --qf "%{SIZE} bytes\n" "$1" > "$3"; exit 0;; - CONTENTS.cpio) $RPM2CPIO "$1" > "$3"; exit 0;; + HEADER) $RPM -qip "$f" > "$3"; exit 0;; + INSTALL) echo "# Run this to install this RPM package" > "$3"; exit 0;; + UPGRADE) echo "# Run this to upgrade this RPM package" > "$3"; exit 0;; + ERROR) $RPM -qip "$f" > /dev/null 2> "$3"; exit 0;; + INFO/NAME-VERSION-RELEASE) $RPM -qp --qf "%{NAME}-%{VERSION}-%{RELEASE}\n" "$f" > "$3"; exit 0;; + INFO/RELEASE) $RPM -qp --qf "%{RELEASE}\n" "$f" > "$3"; exit 0;; + INFO/GROUP) $RPM -qp --qf "%{GROUP}\n" "$f" > "$3"; exit 0;; + INFO/DISTRIBUTION) $RPM -qp --qf "%{DISTRIBUTION}\n" "$f" > "$3"; exit 0;; + INFO/VENDOR) $RPM -qp --qf "%{VENDOR}\n" "$f" > "$3"; exit 0;; + INFO/BUILDHOST) $RPM -qp --qf "%{BUILDHOST}\n" "$f" > "$3"; exit 0;; + INFO/SOURCERPM) $RPM -qp --qf "%{SOURCERPM}\n" "$f" > "$3"; exit 0;; + INFO/DESCRIPTION) $RPM -qp --qf "%{DESCRIPTION}\n" "$f" > "$3"; exit 0;; + INFO/PACKAGER) $RPM -qp --qf "%{PACKAGER}\n" "$f" > "$3"; exit 0;; + INFO/URL) $RPM -qp --qf "%{URL}\n" "$f" >"$3"; exit 0;; + INFO/BUILDTIME) $RPM -qp --qf "%{BUILDTIME:date}\n" "$f" >"$3"; exit 0;; + INFO/SERIAL) $RPM -qp --qf "%{SERIAL}\n" "$f" >"$3"; exit 0;; + INFO/COPYRIGHT) $RPM -qp --qf "%{COPYRIGHT}\n" "$f" >"$3"; exit 0;; + INFO/RPMVERSION) $RPM -qp --qf "%{RPMVERSION}\n" "$f" >"$3"; exit 0;; + INFO/REQUIRENAME) $RPM -qp --qf "[%{REQUIRENAME} %{REQUIREFLAGS:depflags} %{REQUIREVERSION}\n]" "$f" >"$3"; exit 0;; + INFO/PROVIDES) $RPM -qp --qf "[%{PROVIDES}\n]" "$f" >"$3"; exit 0;; + INFO/SCRIPTS/PREIN) $RPM -qp --qf "%{RPMTAG_PREIN}\n" "$f" >"$3"; exit 0;; + INFO/SCRIPTS/POSTIN) $RPM -qp --qf "%{RPMTAG_POSTIN}\n" "$f" >"$3"; exit 0;; + INFO/SCRIPTS/PREUN) $RPM -qp --qf "%{RPMTAG_PREUN}\n" "$f" >"$3"; exit 0;; + INFO/SCRIPTS/POSTUN) $RPM -qp --qf "%{RPMTAG_POSTUN}\n" "$f" >"$3"; exit 0;; + INFO/SCRIPTS/VERIFYSCRIPT) $RPM -qp --qf "%{VERIFYSCRIPT}\n" "$f" >"$3"; exit 0;; + INFO/SCRIPTS/ALL) $RPM -qp --scripts "$f" > "$3"; exit 0;; + INFO/SUMMARY) $RPM -qp --qf "%{SUMMARY}\n" "$f" > "$3"; exit 0;; + INFO/OS) $RPM -qp --qf "%{OS}\n" "$f" > "$3"; exit 0;; + INFO/CHANGELOG) $RPM -qp --qf "[* %{CHANGELOGTIME:date} %{CHANGELOGNAME}\n%{CHANGELOGTEXT}\n\n]\n" "$f" > "$3"; exit 0;; + INFO/SIZE) $RPM -qp --qf "%{SIZE} bytes\n" "$f" > "$3"; exit 0;; + CONTENTS.cpio) $RPM2CPIO "$1" > "$3"; exit 0;; *) - TMPDIR=/tmp/mctmpdir.$$ - mkdir $TMPDIR || exit 1 + TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-rpm.XXXXXX` || exit 1 cd $TMPDIR # Files in RPM version 4 and above start with "./" - try both $RPM2CPIO "$1" | cpio -iumd --quiet "$2" "./$2" >/dev/null @@ -172,9 +180,10 @@ mcrpmfs_run () { + f="`echo "$1" | $SED "$SEDCMD"`" case "$2" in - INSTALL) echo "Installing \"$1\""; $RPM -ivh "$1"; exit 0;; - UPGRADE) echo "Upgrading \"$1\""; $RPM -iUvh "$1"; exit 0;; + INSTALL) echo "Installing \"$1\""; $RPM -ivh "$f"; exit 0;; + UPGRADE) echo "Upgrading \"$1\""; $RPM -Uvh "$f"; exit 0;; esac } diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/uar.in mc-4.6.0/vfs/extfs/uar.in --- mc-4.6.0.orig/vfs/extfs/uar.in 2002-12-12 01:21:35.000000000 -0800 +++ mc-4.6.0/vfs/extfs/uar.in 2004-05-27 12:49:30.000000000 -0700 @@ -22,8 +22,7 @@ mcarfs_copyin () { - TMPDIR=/tmp/mctmpdir-uar.$$ - mkdir $TMPDIR || exit 1 + TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uar.XXXXXX` || exit 1 name=`basename "$2"` (cd $TMPDIR && cp -fp "$3" $name && $XAR r "$1" $name) rm -rf $TMPDIR diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/uha.in mc-4.6.0/vfs/extfs/uha.in --- mc-4.6.0.orig/vfs/extfs/uha.in 2002-12-13 21:10:53.000000000 -0800 +++ mc-4.6.0/vfs/extfs/uha.in 2004-05-27 12:49:30.000000000 -0700 @@ -31,8 +31,7 @@ mchafs_copyout () { - TMPDIR="/tmp/mctmpdir-uha.$$" - mkdir $TMPDIR || exit 1 + TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uha.XXXXXX` || exit 1 cd $TMPDIR $HA xyq "$1" "$2" >/dev/null diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/ulha.in mc-4.6.0/vfs/extfs/ulha.in --- mc-4.6.0.orig/vfs/extfs/ulha.in 2002-12-13 20:39:10.000000000 -0800 +++ mc-4.6.0/vfs/extfs/ulha.in 2004-05-27 12:49:30.000000000 -0700 @@ -35,12 +35,6 @@ LHA_GET="lha pq" LHA_PUT="lha aq" -# Define a directory to create a temporary file for when -# running a command to be run from the archive -TMPDIR="/tmp/mctmpdir-uha.$$" -# Temporary file within the directory -TMPCMD=$TMPDIR/run - # The 'list' command executive mc_lha_fs_list() @@ -121,9 +115,9 @@ mc_lha_fs_run() { + TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-ulha.XXXXXX` || exit 1 trap "rm -rf $TMPDIR; exit 0" 1 2 3 4 15 - # FIXME: Try harder to generate a unique directory if this fails - mkdir -m 0700 $TMPDIR || exit 1 + TMPCMD=$TMPDIR/run $LHA_GET "$1" "$2" > $TMPCMD chmod a+x $TMPCMD $TMPCMD diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/urar.in mc-4.6.0/vfs/extfs/urar.in --- mc-4.6.0.orig/vfs/extfs/urar.in 2003-01-24 07:56:25.000000000 -0800 +++ mc-4.6.0/vfs/extfs/urar.in 2004-05-27 12:49:30.000000000 -0700 @@ -77,8 +77,7 @@ # preserve pwd. It is clean, but is it necessary? pwd=`pwd` # Create a directory and create in it a tmp directory with the good name - dir=tmpdir.${RANDOM} - mkdir $dir + dir=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-urar.XXXXXX` || exit 1 cd $dir mkdir -p "$2" # rar cannot create an empty directory diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/uzip.in mc-4.6.0/vfs/extfs/uzip.in --- mc-4.6.0.orig/vfs/extfs/uzip.in 2002-12-12 01:15:20.000000000 -0800 +++ mc-4.6.0/vfs/extfs/uzip.in 2004-05-27 12:49:31.000000000 -0700 @@ -344,10 +344,10 @@ # Make a temporary directory with mode 0700. sub mktmpdir { - while (1) { - my $dir = POSIX::tmpnam(); - return $dir if mkdir ($dir, 0700); - } + use File::Temp qw(mkdtemp); + my $template = "/tmp/mcuzipfs.XXXXXX"; + $template="$ENV{MC_TMPDIR}/mcuzipfs.XXXXXX" if ($ENV{MC_TMPDIR}); + return mkdtemp($template); } # Make a filename absolute and return it. diff -u -r --new-file mc-4.6.0.orig/vfs/extfs/uzoo.in mc-4.6.0/vfs/extfs/uzoo.in --- mc-4.6.0.orig/vfs/extfs/uzoo.in 2002-12-13 20:29:13.000000000 -0800 +++ mc-4.6.0/vfs/extfs/uzoo.in 2004-05-27 12:49:31.000000000 -0700 @@ -13,8 +13,7 @@ # it to a temporary directory. mklink () { - TMPDIR="/tmp/mctmpdir-uzoo.$$" - mkdir $TMPDIR || exit 1 + TMPDIR=`mktemp -d ${MC_TMPDIR:-/tmp}/mctmpdir-uzoo.XXXXXX` || exit 1 trap 'cd /; rm -rf $TMPDIR' 0 1 2 3 5 13 15 ARCHIVE=$TMPDIR/tmp.zoo ln -sf "$1" "$ARCHIVE" diff -u -r --new-file mc-4.6.0.orig/vfs/extfs.c mc-4.6.0/vfs/extfs.c --- mc-4.6.0.orig/vfs/extfs.c 2002-12-25 13:42:59.000000000 -0800 +++ mc-4.6.0/vfs/extfs.c 2004-05-27 12:49:31.000000000 -0700 @@ -888,8 +888,7 @@ if (!*info) return NULL; - strncpy(dir.dent.d_name, (*info)->name, MC_MAXPATHLEN); - dir.dent.d_name[MC_MAXPATHLEN] = 0; + g_strlcpy(dir.dent.d_name, (*info)->name, MC_MAXPATHLEN); compute_namelen(&dir.dent); *info = (*info)->next_in_dir; @@ -1002,10 +1001,10 @@ if (entry == NULL) return -1; if (!S_ISLNK (entry->inode->mode)) ERRNOR (EINVAL, -1); - if (size > (i = strlen (entry->inode->linkname))) { - size = i; + if (size < (i = strlen (entry->inode->linkname))) { + i = size; } - strncpy (buf, entry->inode->linkname, i); + memcpy (buf, entry->inode->linkname, i); return i; } diff -u -r --new-file mc-4.6.0.orig/vfs/fish.c mc-4.6.0/vfs/fish.c --- mc-4.6.0.orig/vfs/fish.c 2002-12-25 18:21:43.000000000 -0800 +++ mc-4.6.0/vfs/fish.c 2004-05-27 12:49:31.000000000 -0700 @@ -96,8 +96,7 @@ if (strncmp(answer, "### ", 4)) { was_garbage = 1; if (string_buf) { - strncpy(string_buf, answer, string_len - 1); - *(string_buf + string_len - 1) = 0; + g_strlcpy(string_buf, answer, string_len); } } else return decode_reply(answer+4, was_garbage); } @@ -668,7 +667,7 @@ { int r; - r = command (me, super, WAIT_REPLY, cmd); + r = command (me, super, WAIT_REPLY, "%s", cmd); vfs_add_noncurrent_stamps (&vfs_fish_ops, (vfsid) super, NULL); if (r != COMPLETE) ERRNOR (E_REMOTE, -1); if (flags & OPT_FLUSH) diff -u -r --new-file mc-4.6.0.orig/vfs/ftpfs.c mc-4.6.0/vfs/ftpfs.c --- mc-4.6.0.orig/vfs/ftpfs.c 2002-12-25 18:21:43.000000000 -0800 +++ mc-4.6.0/vfs/ftpfs.c 2004-05-27 12:49:31.000000000 -0700 @@ -266,8 +266,7 @@ switch (sscanf(answer, "%d", &code)){ case 0: if (string_buf) { - strncpy (string_buf, answer, string_len - 1); - *(string_buf + string_len - 1) = 0; + g_strlcpy (string_buf, answer, string_len); } code = 500; return 5; @@ -286,8 +285,7 @@ } } if (string_buf){ - strncpy (string_buf, answer, string_len - 1); - *(string_buf + string_len - 1) = 0; + g_strlcpy (string_buf, answer, string_len); } return code / 100; } @@ -321,28 +319,28 @@ va_list ap; char *str, *fmt_str; int status; - int sock = SUP.sock; + int cmdlen; va_start (ap, fmt); fmt_str = g_strdup_vprintf (fmt, ap); va_end (ap); - status = strlen (fmt_str); - str = g_realloc (fmt_str, status + 3); - strcpy (str + status, "\r\n"); + cmdlen = strlen (fmt_str); + str = g_realloc (fmt_str, cmdlen + 3); + strcpy (str + cmdlen, "\r\n"); if (logfile){ if (strncmp (str, "PASS ", 5) == 0){ fputs ("PASS \r\n", logfile); } else - fwrite (str, status + 2, 1, logfile); + fwrite (str, cmdlen + 2, 1, logfile); fflush (logfile); } got_sigpipe = 0; enable_interrupt_key (); - status = write (SUP.sock, str, status + 2); + status = write (SUP.sock, str, cmdlen + 2); if (status < 0){ code = 421; @@ -353,7 +351,7 @@ level = 1; status = reconnect (me, super); level = 0; - if (status && write (SUP.sock, str, status + 2) > 0) + if (status && write (SUP.sock, str, cmdlen + 2) > 0) goto ok; } got_sigpipe = 1; @@ -367,7 +365,7 @@ disable_interrupt_key (); if (wait_reply) - return get_reply (me, sock, (wait_reply & WANT_STRING) ? reply_str : NULL, sizeof (reply_str)-1); + return get_reply (me, SUP.sock, (wait_reply & WANT_STRING) ? reply_str : NULL, sizeof (reply_str)-1); return COMPLETE; } @@ -903,23 +901,29 @@ int data, len = sizeof(data_addr); struct protoent *pe; - getsockname(SUP.sock, (struct sockaddr *) &data_addr, &len); - data_addr.sin_port = 0; - pe = getprotobyname("tcp"); if (pe == NULL) ERRNOR (EIO, -1); +again: + if (getsockname(SUP.sock, (struct sockaddr *) &data_addr, &len) == -1) + ERRNOR (EIO, -1); + data_addr.sin_port = 0; + data = socket (AF_INET, SOCK_STREAM, pe->p_proto); if (data < 0) ERRNOR (EIO, -1); if (SUP.use_passive_connection){ - if ((SUP.use_passive_connection = setup_passive (me, super, data, &data_addr))) + if (setup_passive (me, super, data, &data_addr)) return data; SUP.use_source_route = 0; SUP.use_passive_connection = 0; print_vfs_message (_("ftpfs: could not setup passive mode")); + + /* data or data_addr may be damaged by setup_passive */ + close (data); + goto again; } /* If passive setup fails, fallback to active connections */ @@ -971,11 +975,12 @@ data = s; else { data = accept (s, (struct sockaddr *)&from, &fromlen); - close(s); if (data < 0) { my_errno = errno; + close(s); return -1; } + close(s); } disable_interrupt_key(); return data; @@ -1019,6 +1024,7 @@ gettimeofday (&tim, NULL); if (tim.tv_sec > start_tim.tv_sec + ABORT_TIMEOUT) { /* server keeps sending, drop the connection and reconnect */ + close (dsock); reconnect (me, super); return; } diff -u -r --new-file mc-4.6.0.orig/vfs/mcfs.c mc-4.6.0/vfs/mcfs.c --- mc-4.6.0.orig/vfs/mcfs.c 2002-11-14 23:49:39.000000000 -0800 +++ mc-4.6.0/vfs/mcfs.c 2004-05-27 12:49:31.000000000 -0700 @@ -756,8 +756,7 @@ return NULL; } dirent_dest = mcfs_readdir_data.dent.d_name; - strncpy (dirent_dest, mcfs_info->current->text, MC_MAXPATHLEN); - dirent_dest[MC_MAXPATHLEN] = 0; + g_strlcpy (dirent_dest, mcfs_info->current->text, MC_MAXPATHLEN); cached_lstat_info = &mcfs_info->current->my_stat; mcfs_info->current = mcfs_info->current->next; @@ -985,9 +984,12 @@ if (!rpc_get (mc->sock, RPC_STRING, &stat_str, RPC_END)) return the_error (-1, EIO); - strncpy (buf, stat_str, size); + status = strlen (stat_str); + if (status < size) + size = status; + memcpy (buf, stat_str, size); g_free (stat_str); - return strlen (buf); + return size; } static int diff -u -r --new-file mc-4.6.0.orig/vfs/mcserv.c mc-4.6.0/vfs/mcserv.c --- mc-4.6.0.orig/vfs/mcserv.c 2002-12-07 17:12:30.000000000 -0800 +++ mc-4.6.0/vfs/mcserv.c 2004-05-27 12:49:31.000000000 -0700 @@ -582,7 +582,7 @@ int n; rpc_get (msock, RPC_STRING, &file, RPC_END); - n = readlink (file, buffer, 2048); + n = readlink (file, buffer, 2048 - 1); send_status (n, errno); if (n >= 0) { buffer[n] = 0; diff -u -r --new-file mc-4.6.0.orig/vfs/names.c mc-4.6.0/vfs/names.c --- mc-4.6.0.orig/vfs/names.c 2002-11-14 22:19:34.000000000 -0800 +++ mc-4.6.0/vfs/names.c 2004-05-27 12:49:31.000000000 -0700 @@ -31,6 +31,7 @@ #include #include #include +#include #include "names.h" @@ -59,7 +60,7 @@ if (uname[0] != saveuname[0] /* Quick test w/o proc call */ ||0 != strncmp (uname, saveuname, TUNMLEN)) { - strncpy (saveuname, uname, TUNMLEN); + g_strlcpy (saveuname, uname, TUNMLEN); pw = getpwnam (uname); if (pw) { saveuid = pw->pw_uid; @@ -77,7 +78,7 @@ if (gname[0] != savegname[0] /* Quick test w/o proc call */ ||0 != strncmp (gname, savegname, TUNMLEN)) { - strncpy (savegname, gname, TUNMLEN); + g_strlcpy (savegname, gname, TUNMLEN); gr = getgrnam (gname); if (gr) { savegid = gr->gr_gid; diff -u -r --new-file mc-4.6.0.orig/vfs/samba/lib/util.c mc-4.6.0/vfs/samba/lib/util.c --- mc-4.6.0.orig/vfs/samba/lib/util.c 2002-11-15 09:02:44.000000000 -0800 +++ mc-4.6.0/vfs/samba/lib/util.c 2004-05-27 12:49:31.000000000 -0700 @@ -114,7 +114,7 @@ char *tmpdir(void) { char *p; - if ((p = getenv("TMPDIR"))) { + if ((p = getenv("MC_TMPDIR")) || (p = getenv("TMPDIR"))) { return p; } return "/tmp"; @@ -1885,20 +1885,17 @@ char *nis_map = (char *)lp_nis_home_map_name(); - char nis_domain[NIS_MAXNAMELEN + 1]; char buffer[NIS_MAXATTRVAL + 1]; nis_result *result; nis_object *object; entry_obj *entry; - strncpy(nis_domain, (char *)nis_local_directory(), NIS_MAXNAMELEN); - nis_domain[NIS_MAXNAMELEN] = '\0'; - - DEBUG(5, ("NIS+ Domain: %s\n", nis_domain)); + DEBUG(5, ("NIS+ Domain: %s\n", (char *)nis_local_directory())); if (strcmp(user_name, last_key)) { - slprintf(buffer, sizeof(buffer)-1, "[%s=%s]%s.%s", "key", user_name, nis_map, nis_domain); + slprintf(buffer, sizeof(buffer)-1, "[%s=%s]%s.%s", "key", user_name, nis_map, + (char *)nis_local_directory()); DEBUG(5, ("NIS+ querystring: %s\n", buffer)); if (result = nis_list(buffer, RETURN_RESULT, NULL, NULL)) diff -u -r --new-file mc-4.6.0.orig/vfs/smbfs.c mc-4.6.0/vfs/smbfs.c --- mc-4.6.0.orig/vfs/smbfs.c 2003-01-24 13:37:29.000000000 -0800 +++ mc-4.6.0/vfs/smbfs.c 2004-05-27 12:49:31.000000000 -0700 @@ -785,8 +785,7 @@ #endif return NULL; } - strncpy(dirent_dest, smbfs_info->current->text, MC_MAXPATHLEN); - dirent_dest[MC_MAXPATHLEN] = 0; + g_strlcpy(dirent_dest, smbfs_info->current->text, MC_MAXPATHLEN); smbfs_info->current = smbfs_info->current->next; compute_namelen(&smbfs_readdir_data.dent); diff -u -r --new-file mc-4.6.0.orig/vfs/tar.c mc-4.6.0/vfs/tar.c --- mc-4.6.0.orig/vfs/tar.c 2002-12-07 17:12:30.000000000 -0800 +++ mc-4.6.0/vfs/tar.c 2004-05-27 12:49:31.000000000 -0700 @@ -264,19 +264,26 @@ char *bp, *data; int size, written; + if (hstat.st_size > MC_MAXPATHLEN) { + message_1s (1, MSG_ERROR, _("Inconsistent tar archive")); + return STATUS_BADCHECKSUM; + } + longp = ((header->header.linkflag == LF_LONGNAME) ? &next_long_name : &next_long_link); if (*longp) g_free (*longp); - bp = *longp = g_malloc (hstat.st_size); + bp = *longp = g_malloc (hstat.st_size + 1); for (size = hstat.st_size; size > 0; size -= written) { data = get_next_record (archive, tard)->charptr; if (data == NULL) { + g_free (*longp); + *longp = NULL; message_1s (1, MSG_ERROR, _("Unexpected EOF on archive file")); return STATUS_BADCHECKSUM; } @@ -287,10 +294,14 @@ memcpy (bp, data, written); bp += written; } -#if 0 - if (hstat.st_size > 1) - bp [hstat.st_size - 1] = 0; /* just to make sure */ -#endif + + if (bp - *longp == MC_MAXPATHLEN && bp[-1] != '\0') { + g_free (*longp); + *longp = NULL; + message_1s (1, MSG_ERROR, _("Inconsistent tar archive")); + return STATUS_BADCHECKSUM; + } + *bp = 0; goto recurse; } else { struct stat st; diff -u -r --new-file mc-4.6.0.orig/vfs/vfs.c mc-4.6.0/vfs/vfs.c --- mc-4.6.0.orig/vfs/vfs.c 2002-12-25 18:21:43.000000000 -0800 +++ mc-4.6.0/vfs/vfs.c 2004-05-27 12:49:31.000000000 -0700 @@ -637,8 +637,7 @@ { const char *cwd = mc_return_cwd(); - strncpy (buffer, cwd, size - 1); - buffer [size - 1] = 0; + g_strlcpy (buffer, cwd, size); return buffer; }