[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FDclone-users:00945] Re: HTTPLOGFILE 書き込み時に SEGV



 しらいです。

 えーと、MIME encoding なメールが読めない人なので、出来れば
本文は ISO-2022-JP で書いて貰えると助かります。Apple Mail の
設定方法は知りませんが、設定で回避不能なのかしらん?

In Message-Id <D3A53291-2F79-4BF6-BD90-A30D2382182A@miko.org>
        Takanori Yamamoto <tatyana@miko.org>さんwrites:
> 山本です。

> FD 3.00j において、URLDRIVE が有効にし、かつ HTTPLOGFILE にてログファイルを生成 する設定にした場合、SEGV が発生します。
> FreeBSD 9.0/amd64 と Mac OS X Lion にて現象を確認しています。

 手元にある近い環境では FreeBSD 6.2 と Mac OS X Leopard が
あるのですが、どちらでも再現しませんでした。最近の stdarg の
トレンドなんでしょうかね?


> 添付のパッチで回避できるようです。

 うーむ、確かに va_start() と va_end() の間に複数回 args を
利用する code は余り見たことありませんけど、この patch のよ
うに va_start/va_end 自体を複数回というのも見ません。
 これらの関数は macro を実体とするもので、実装にかなり依存
してしまいますので、FreeBSD 9 と Lion とで動くようになった一
方で、どこか別の環境では動かなくなる可能性が危惧されます。

 どういう環境でも問題なく動きそうな patch に改めてみました
ので、こちらでご確認下さい。

---- Cut Here ----
diff -ur ../old/FD-3.00j/http.c ./http.c
--- ../old/FD-3.00j/http.c	Sat Sep 25 00:00:00 2010
+++ ./http.c	Sun Mar 11 01:42:55 2012
@@ -64,6 +64,7 @@
 static VOID NEAR vhttplog __P_((CONST char *, va_list));
 static VOID NEAR httplog __P_((CONST char *, ...));
 static char *NEAR httprecv __P_((XFILE *));
+static int NEAR vhttpsend __P_((XFILE *, CONST char *, va_list));
 static int NEAR httpsend __P_((XFILE *, CONST char *, ...));
 static int NEAR getcode __P_((CONST char *, int *));
 static VOID NEAR httpflush __P_((int));
@@ -188,6 +189,23 @@
 	return(buf);
 }
 
+static int NEAR vhttpsend(fp, fmt, args)
+XFILE *fp;
+CONST char *fmt;
+va_list args;
+{
+	char buf[URLMAXCMDLINE + 1];
+	int n;
+
+	n = Xsnprintf(buf, sizeof(buf), "--> \"%s\"\n", fmt);
+	if (n >= 0) vhttplog(buf, args);
+
+	n = Xvfprintf(fp, fmt, args);
+	if (n >= 0) n = fputnl(fp);
+
+	return(n);
+}
+
 #ifdef	USESTDARGH
 /*VARARGS2*/
 static int NEAR httpsend(XFILE *fp, CONST char *fmt, ...)
@@ -200,15 +218,10 @@
 #endif
 {
 	va_list args;
-	char buf[URLMAXCMDLINE + 1];
 	int n;
 
 	VA_START(args, fmt);
-	n = Xsnprintf(buf, sizeof(buf), "--> \"%s\"\n", fmt);
-	if (n >= 0) vhttplog(buf, args);
-
-	n = Xvfprintf(fp, fmt, args);
-	if (n >= 0) n = fputnl(fp);
+	n = vhttpsend(fp, fmt, args);
 	va_end(args);
 
 	return(n);
---- Cut Here ----

                                               しらい たかし