Re: write18の注意点

名前: ttk
日時: 2007-10-25 02:29:41
IPアドレス: 61.210.53.*

>>49907 おっしゃる通りでした。 ソースを眺めてみると、 途中で system 関数を呼び出しており、 その文字列が任意になっているようです。 下記の該当部分と思われるところは、 コンパイルの際に tex1.c に現われます。 この system 関数にかぶせて安全なコマンドしか実行できないようにするラッパーを C言語で書いて差し替えてしまえばよろしいのではないでしょうか? (動作未確認) tex.ch より抜粋:: if shell_enabled_p then begin str_room(1); append_char(0); {Append a null byte to the expansion.} clobbered:=false; for d:=0 to cur_length-1 do {Convert to external character set.} begin str_pool[str_start[str_ptr]+d]:=xchr[str_pool[str_start[str_ptr]+d]]; if (str_pool[str_start[str_ptr]+d]=null_code) and (d<cur_length-1) then clobbered:=true; {minimal checking: NUL not allowed in argument string of |system|()} end; if clobbered then print("clobbered") else begin {We have the string; run system(3). We don't have anything reasonable to do with the return status, unfortunately discard it.} system(stringcast(address_of(str_pool[str_start[str_ptr]]))); <<<=== !!ここ!! print("executed"); end; pool_ptr:=str_start[str_ptr]; {erase the string} end

この書き込みへの返事:

お名前
題名 
メッセージ(タグは <a href="...">...</a> だけ使えます。適宜改行を入れてください)