Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jun 2008 05:10:04 GMT
From:      "Garrett Cooper" <yanefbsd@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/83358: [patch] improper handling of malloc failures within rexec()
Message-ID:  <200806210510.m5L5A4AT039615@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/83358; it has been noted by GNATS.

From: "Garrett Cooper" <yanefbsd@gmail.com>
To: bug-followup@FreeBSD.org, dan@obluda.cz
Cc:  
Subject: Re: bin/83358: [patch] improper handling of malloc failures within rexec()
Date: Fri, 20 Jun 2008 22:07:16 -0700

 ------=_Part_14701_30557979.1214024836491
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline
 
 This patch includes the fixes provided previously (minus the port var
 removal provided by the OP), plus some style fixes and source
 updating.
 
 Which makes me wonder: is libcompat-4.3's rexec.c used for compiling
 purposes at all?
 
 -Garrett
 
 ------=_Part_14701_30557979.1214024836491
 Content-Type: text/x-patch; name=4_3_compat_update.patch
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_fhpr0ztf0
 Content-Disposition: attachment; filename=4_3_compat_update.patch
 
 SW5kZXg6IGNmcmVlLmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PT09PT09PT09PT09PT09PQpSQ1MgZmlsZTogL2hvbWUvbmN2cy9zcmMvbGliL2xp
 YmNvbXBhdC80LjMvY2ZyZWUuYyx2CnJldHJpZXZpbmcgcmV2aXNpb24gMS4zCmRpZmYgLXUgLXIx
 LjMgY2ZyZWUuYwotLS0gY2ZyZWUuYwk5IEphbiAyMDA3IDAxOjAyOjAyIC0wMDAwCTEuMworKysg
 Y2ZyZWUuYwkyMSBKdW4gMjAwOCAwNDo1MjoxMSAtMDAwMApAQCAtMzcsOCArMzcsNyBAQAogI2lu
 Y2x1ZGUgPHN0ZGxpYi5oPgogCiB2b2l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KmNwKysgPSBjOwot
 CQl9Ci0JfSBlbHNlIHsKLQkJKmNwKysgPSBjOwotCQl3aGlsZSAoKGMgPSBnZXRjKGNmaWxlKSkg
 IT0gRU9GCi0JCSAgICAmJiBjICE9ICdcbicgJiYgYyAhPSAnXHQnICYmIGMgIT0gJyAnICYmIGMg
 IT0gJywnKSB7Ci0JCQlpZiAoYyA9PSAnXFwnKQotCQkJCWMgPSBnZXRjKGNmaWxlKTsKLQkJCSpj
 cCsrID0gYzsKLQkJfQotCX0KLQkqY3AgPSAwOwotCWlmICh0b2t2YWxbMF0gPT0gMCkKLQkJcmV0
 dXJuICgwKTsKLQlmb3IgKHQgPSB0b2t0YWI7IHQtPnRva3N0cjsgdCsrKQotCQlpZiAoIXN0cmNt
 cCh0LT50b2tzdHIsIHRva3ZhbCkpCi0JCQlyZXR1cm4gKHQtPnR2YWwpOwotCXJldHVybiAoSUQp
 OworICAgICAgICBjaGFyICpjcDsKKyAgICAgICAgaW50IGM7CisgICAgICAgIHN0cnVjdCB0b2t0
 YWIgKnQ7CisKKyAgICAgICAgaWYgKGZlb2YoY2ZpbGUpIHx8IGZlcnJvcihjZmlsZSkpCisgICAg
 ICAgICAgICByZXR1cm4gKDApOworICAgICAgICB3aGlsZSAoKGMgPSBnZXRjKGNmaWxlKSkgIT0g
 RU9GICYmCisgICAgICAgICAgICAoYyA9PSAnXG4nIHx8IGMgPT0gJ1x0JyB8fCBjID09ICcgJyB8
 fCBjID09ICcsJykpCisgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgaWYgKGMgPT0gRU9G
 KQorICAgICAgICAgICAgcmV0dXJuICgwKTsKKyAgICAgICAgY3AgPSB0b2t2YWw7CisgICAgICAg
 IGlmIChjID09ICciJykgeworICAgICAgICAgICAgd2hpbGUgKChjID0gZ2V0YyhjZmlsZSkpICE9
 IEVPRiAmJiBjICE9ICciJykgeworICAgICAgICAgICAgICAgIGlmIChjID09ICdcXCcpCisgICAg
 ICAgICAgICAgICAgICAgIGMgPSBnZXRjKGNmaWxlKTsKKyAgICAgICAgICAgICAgICAqY3ArKyA9
 IGM7CisgICAgICAgICAgICB9CisgICAgICAgIH0gZWxzZSB7CisgICAgICAgICAgICAqY3ArKyA9
 IGM7CisgICAgICAgICAgICB3aGlsZSAoKGMgPSBnZXRjKGNmaWxlKSkgIT0gRU9GCisgICAgICAg
 ICAgICAgICAgJiYgYyAhPSAnXG4nICYmIGMgIT0gJ1x0JyAmJiBjICE9ICcgJyAmJiBjICE9ICcs
 JykgeworICAgICAgICAgICAgICAgIGlmIChjID09ICdcXCcpCisgICAgICAgICAgICAgICAgICAg
 IGMgPSBnZXRjKGNmaWxlKTsKKyAgICAgICAgICAgICAgICAqY3ArKyA9IGM7CisgICAgICAgICAg
 ICB9CisgICAgICAgIH0KKyAgICAgICAgKmNwID0gMDsKKyAgICAgICAgaWYgKHRva3ZhbFswXSA9
 PSAwKQorICAgICAgICAgICAgcmV0dXJuICgwKTsKKyAgICAgICAgZm9yICh0ID0gdG9rdGFiOyB0
 LT50b2tzdHI7IHQrKykKKyAgICAgICAgICAgIGlmICghc3RyY21wKHQtPnRva3N0ciwgdG9rdmFs
 KSkKKyAgICAgICAgICAgICAgICByZXR1cm4gKHQtPnR2YWwpOworICAgICAgICByZXR1cm4gKElE
 KTsKIH0KIAogc3RhdGljIGludAotcnVzZXJwYXNzKGhvc3QsIGFuYW1lLCBhcGFzcywgYWFjY3Qp
 Ci0JY2hhciAqaG9zdCwgKiphbmFtZSwgKiphcGFzcywgKiphYWNjdDsKK3J1c2VycGFzcyhjaGFy
 ICpob3N0LCBjaGFyICoqYW5hbWUsIGNoYXIgKiphcGFzcywgY2hhciAqKmFhY2N0KQogewotCWNo
 YXIgKmhkaXIsIGJ1ZltCVUZTSVpdLCAqdG1wOwotCWNoYXIgbXluYW1lW01BWEhPU1ROQU1FTEVO
 XSwgKm15ZG9tYWluOwotCWludCB0LCBpLCBjLCB1c2VkZWZhdWx0ID0gMDsKLQlzdHJ1Y3Q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gZm9wZW4oYnVmLCAiciIpOworICAgICAgICBpZiAoY2ZpbGUgPT0gTlVMTCkgewor
 ICAgICAgICAgICAgaWYgKGVycm5vICE9IEVOT0VOVCkKKyAgICAgICAgICAgICAgICB3YXJuKCIl
 cyIsIGJ1Zik7CisgICAgICAgICAgICByZXR1cm4gKDApOworICAgICAgICB9CisgICAgICAgIGlm
 IChnZXRob3N0bmFtZShteW5hbWUsIHNpemVvZihteW5hbWUpKSA8IDApCisgICAgICAgICAgICBt
 eW5hbWVbMF0gPSAnXDAnOworICAgICAgICBpZiAoKG15ZG9tYWluID0gc3RyY2hyKG15bmFtZSwg
 Jy4nKSkgPT0gTlVMTCkKKyAgICAgICAgICAgIG15ZG9tYWluID0gIiI7CiBuZXh0OgotCXdoaWxl
 ICgodCA9IHRva2VuKCkpKSBzd2l0Y2godCkgeworICAgICAgICB3aGlsZSAoKHQgPSB0b2tlbigp
 KSAhPSAwKSB7CisKKyAgICAgICAgICAgIHN3aXRjaCh0KSB7CisgICAgICAgICAgICBjYXNlIERF
 RkFVTFQ6CisgICAgICAgICAgICAgICAgdXNlZGVmYXVsdCA9IDE7CisgICAgICAgICAgICAgICAg
 LyogRkFMTCBUSFJPVUdIICovCisKKyAgICAgICAgICAgIGNhc2UgTUFDSDoKKyAgICAgICAgICAg
 ICAgICBpZiAoIXVzZWRlZmF1bHQpIHsKKyAgICAgICAgICAgICAgICAgICAgaWYgKHRva2VuKCkg
 IT0gSUQpCisgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKKyAgICAgICAgICAgICAg
 ICAgICAgLyoKKyAgICAgICAgICAgICAgICAgICAgICogQWxsb3cgbWF0Y2ggZWl0aGVyIGZvciB1
 c2VyJ3MgaW5wdXQgaG9zdAorICAgICAgICAgICAgICAgICAgICAgKiBuYW1lIG9yIG9mZmljaWFs
 IGhvc3RuYW1lLiAgQWxzbyBhbGxvdyBtYXRjaAorICAgICAgICAgICAgICAgICAgICAgKiBvZiBp
 bmNvbXBsZXRlbHktc3BlY2lmaWVkIGhvc3QgaW4gbG9jYWwKKyAgICAgICAgICAgICAgICAgICAg
 ICogZG9tYWluLgorICAgICAgICAgICAgICAgICAgICAgKi8KKyAgICAgICAgICAgICAgICAgICAg
 aWYgKHN0cmNhc2VjbXAoaG9zdCwgdG9rdmFsKSA9PSAwKQorICAgICAgICAgICAgICAgICAgICAg
 ICAgZ290byBtYXRjaDsKKyAgICAgICAgICAgICAgICAgICAgaWYgKCh0bXAgPSBzdHJjaHIoaG9z
 dCwgJy4nKSkgIT0gTlVMTCAmJgorICAgICAgICAgICAgICAgICAgICAgICAgc3RyY2FzZWNtcCh0
 bXAsIG15ZG9tYWluKSA9PSAwICYmCisgICAgICAgICAgICAgICAgICAgICAgICBzdHJuY2FzZWNt
 cChob3N0LCB0b2t2YWwsIHRtcC1ob3N0KSA9PSAwICYmCisgICAgICAgICAgICAgICAgICAgICAg
 ICB0b2t2YWxbdG1wIC0gaG9zdF0gPT0gJ1wwJykgeworICAgICAgICAgICAgICAgICAgICAgICAg
 Z290byBtYXRjaDsKKyAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICBj
 b250aW51ZTsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICBtYXRjaDoKKyAgICAgICAg
 ICAgICAgICB3aGlsZSAoKHQgPSB0b2tlbigpKSAmJiB0ICE9IE1BQ0ggJiYgdCAhPSBERUZBVUxU
 KSB7CisgICAgICAgICAgICAgICAgICAgIHN3aXRjaCh0KSB7CisgICAgICAgICAgICAgICAgICAg
 IGNhc2UgTE9HSU46CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAodG9rZW4oKSkgeworICAg
 ICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgqYW5hbWUgPT0gMCkgeworICAgICAgICAgICAg
 ICAgICAgICAgICAgICAgICAgICAqYW5hbWUgPSBtYWxsb2Moc3RybGVuKHRva3ZhbCkrMSk7Cisg
 ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgqYW5hbWUgPT0gTlVMTCkgeworICAg
 ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FybngoIm1hbGxvYyBmb3IgYW5hbWUg
 ZmFpbGVkXG4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gYmFk
 OworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAg
 ICAgICAgICAgICAgIHN0cmNweSgqYW5hbWUsIHRva3ZhbCk7CisgICAgICAgICAgICAgICAgICAg
 ICAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN0
 cmNtcCgqYW5hbWUsIHRva3ZhbCkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
 ICBnb3RvIG5leHQ7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAg
 ICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAg
 ICAgICAgICAgIGNhc2UgUEFTU1dEOgorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCgqYW5h
 bWUgPT0gMCB8fCBzdHJjbXAoKmFuYW1lLCAiYW5vbnltb3VzIikpICYmCisgICAgICAgICAgICAg
 ICAgICAgICAgICAgICAgZnN0YXQoZmlsZW5vKGNmaWxlKSwgJnN0YikgPj0gMCAmJgorICAgICAg
 ICAgICAgICAgICAgICAgICAgICAgIChzdGIuc3RfbW9kZSAmIDA3NykgIT0gMCkgeworICAgICAg
 ICAgICAgICAgICAgICAgICAgICAgIHdhcm54KCJFcnJvcjogLm5ldHJjIGZpbGUgaXMgcmVhZGFi
 bGUiCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICIgYnkgb3RoZXJzLlxuUmVtb3Zl
 IHBhc3N3b3JkIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIG9yIG1ha2UgZmls
 ZSB1bnJlYWRhYmxlIGJ5IgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiIG90aGVy
 cy5cbiIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gYmFkOworICAgICAgICAg
 ICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHRva2VuKCkgJiYg
 KmFwYXNzID09IE5VTEwpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAqYXBhc3MgPSBt
 YWxsb2Moc3RybGVuKHRva3ZhbCkrMSk7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYg
 KCphcGFzcyA9PSBOVUxMKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm54
 KCJtYWxsb2MgZm9yIGFwYXNzIGZhaWxlZFxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICAg
 ICAgICAgIGdvdG8gYmFkOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAg
 ICAgICAgICAgICAgICAgICAgICBzdHJjcHkoKmFwYXNzLCB0b2t2YWwpOworICAgICAgICAgICAg
 ICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CisgICAgICAgICAg
 ICAgICAgICAgIGNhc2UgQUNDT1VOVDoKKyAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmc3Rh
 dChmaWxlbm8oY2ZpbGUpLCAmc3RiKSA+PSAwCisgICAgICAgICAgICAgICAgICAgICAgICAgICAg
 JiYgKHN0Yi5zdF9tb2RlICYgMDc3KSAhPSAwKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAg
 ICAgd2FybngoIkVycm9yOiAubmV0cmMgZmlsZSBpcyByZWFkYWJsZSIKKyAgICAgICAgICAgICAg
 ICAgICAgICAgICAgICAgICAgIiBieSBvdGhlcnMuXG5SZW1vdmUgYWNjb3VudCIKKyAgICAgICAg
 ICAgICAgICAgICAgICAgICAgICAgICAgIiBvciBtYWtlIGZpbGUgdW5yZWFkYWJsZSBieSIKKyAg
 ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIiBvdGhlcnMuXG4iKTsKKyAgICAgICAgICAg
 ICAgICAgICAgICAgICAgICBnb3RvIGJhZDsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAg
 ICAgICAgICAgICAgICAgICAgICAgIGlmICh0b2tlbigpICYmICphYWNjdCA9PSBOVUxMKSB7Cisg
 ICAgICAgICAgICAgICAgICAgICAgICAgICAgKmFhY2N0ID0gbWFsbG9jKHN0cmxlbih0b2t2YWwp
 KzEpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgqYWFjY3QgPT0gTlVMTCkgewor
 ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3YXJueCgibWFsbG9jIGZvciBhYWNjdCBm
 YWlsZWRcbiIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIGJhZDsKKyAg
 ICAgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAg
 c3RyY3B5KCphYWNjdCwgdG9rdmFsKTsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAg
 ICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAgICAgICAgICAgICAgICAgICBjYXNlIE1BQ0RF
 RjoKKyAgICAgICAgICAgICAgICAgICAgICAgIHdoaWxlICgoYz1nZXRjKGNmaWxlKSkgIT0gRU9G
 ICYmCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgKGMgPT0gJyAnIHx8IGMgPT0gJ1x0Jykp
 IHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAvKiBOdWxsIGxvb3AgYm9keSAqLworICAg
 ICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGMgPT0g
 RU9GIHx8IGMgPT0gJ1xuJykgeworICAgICAgICAgICAgICAgICAgICAgICAgICAgIHdhcm54KCJN
 aXNzaW5nIG1hY2RlZiBuYW1lIGFyZ3VtZW50LlxuIik7CisgICAgICAgICAgICAgICAgICAgICAg
 ICAgICAgZ290byBiYWQ7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAg
 ICAgICAgICAgICBpZiAobWFjbnVtID09IDE2KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAg
 ICAgd2FybngoIkxpbWl0IG9mIDE2IG1hY3JvcyBoYXZlIGFscmVhZHkgYmVlbiBkZWZpbmVkXG4i
 KTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBnb3RvIGJhZDsKKyAgICAgICAgICAgICAg
 ICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAgIHRtcCA9IG1hY3Jvc1ttYWNudW1d
 Lm1hY19uYW1lOworICAgICAgICAgICAgICAgICAgICAgICAgKnRtcCsrID0gYzsKKyAgICAgICAg
 ICAgICAgICAgICAgICAgIGZvciAoaT0wOyBpIDwgOCAmJiAoYz1nZXRjKGNmaWxlKSkgIT0gRU9G
 ICYmICFpc3NwYWNlKGMpOyArK2kpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAqdG1w
 KysgPSBjOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAg
 ICAgaWYgKGMgPT0gRU9GKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2FybngoIk1h
 Y3JvIGRlZmluaXRpb24gbWlzc2luZyBudWxsIgorICAgICAgICAgICAgICAgICAgICAgICAgICAg
 ICAgICAiIGxpbmUgdGVybWluYXRvci5cbiIpOworICAgICAgICAgICAgICAgICAgICAgICAgICAg
 IGdvdG8gYmFkOworICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAg
 ICAgICAgKnRtcCA9ICdcMCc7CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYyAhPSAnXG4n
 KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKChjPWdldGMoY2ZpbGUpKSAh
 PSBFT0YgJiYgYyAhPSAnXG4nKSA7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAgICAg
 ICAgICAgICAgICAgICAgICBpZiAoYyA9PSBFT0YpIHsKKyAgICAgICAgICAgICAgICAgICAgICAg
 ICAgICB3YXJueCgiTWFjcm8gZGVmaW5pdGlvbiBtaXNzaW5nIG51bGwiCisgICAgICAgICAgICAg
 ICAgICAgICAgICAgICAgICAgICIgbGluZSB0ZXJtaW5hdG9yLlxuIik7CisgICAgICAgICAgICAg
 ICAgICAgICAgICAgICAgZ290byBiYWQ7CisgICAgICAgICAgICAgICAgICAgICAgICB9CisgICAg
 ICAgICAgICAgICAgICAgICAgICBpZiAobWFjbnVtID09IDApIHsKKyAgICAgICAgICAgICAgICAg
 ICAgICAgICAgICBtYWNyb3NbbWFjbnVtXS5tYWNfc3RhcnQgPSBtYWNidWY7CisgICAgICAgICAg
 ICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHsKKyAgICAgICAg
 ICAgICAgICAgICAgICAgICAgICBtYWNyb3NbbWFjbnVtXS5tYWNfc3RhcnQgPQorICAgICAgICAg
 ICAgICAgICAgICAgICAgICAgICAgICBtYWNyb3NbbWFjbnVtLTFdLm1hY19lbmQgKyAxOworICAg
 ICAgICAgICAgICAgICAgICAgICAgfQorICAgICAgICAgICAgICAgICAgICAgICAgdG1wID0gbWFj
 cm9zW21hY251bV0ubWFjX3N0YXJ0OworICAgICAgICAgICAgICAgICAgICAgICAgd2hpbGUgKHRt
 cCAhPSBtYWNidWYgKyA0MDk2KSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChj
 PWdldGMoY2ZpbGUpKSA9PSBFT0YpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
 d2FybngoIk1hY3JvIGRlZmluaXRpb24gbWlzc2luZyIKKyAgICAgICAgICAgICAgICAgICAgICAg
 ICAgICAgICAgICAgICIgbnVsbCBsaW5lIgorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
 ICAgICAgIiB0ZXJtaW5hdG9yLlxuIik7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
 IGdvdG8gYmFkOworICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAg
 ICAgICAgICAgICAgICAqdG1wID0gYzsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAo
 KnRtcCA9PSAnXG4nKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgqKHRt
 cC0xKSA9PSAnXDAnKSB7CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1hY3Jv
 c1ttYWNudW0rK10ubWFjX2VuZCA9IHRtcC0xOworICAgICAgICAgICAgICAgICAgICAgICAgICAg
 ICAgICAgICBicmVhazsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQorICAgICAg
 ICAgICAgICAgICAgICAgICAgICAgICAgICAqdG1wID0gJ1wwJzsKKyAgICAgICAgICAgICAgICAg
 ICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgdG1wKys7CisgICAgICAg
 ICAgICAgICAgICAgICAgICB9CisgICAgICAgICAgICAgICAgICAgICAgICBpZiAodG1wID09IG1h
 Y2J1ZiArIDQwOTYpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICB3YXJueCgiNEsgbWFj
 cm8gYnVmZmVyIGV4Y2VlZGVkXG4iKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICBnb3Rv
 IGJhZDsKKyAgICAgICAgICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICAgICAgICAg
 IGJyZWFrOworICAgICAgICAgICAgICAgICAgICBkZWZhdWx0OgorICAgICAgICAgICAgICAgICAg
 ICAgICAgd2FybngoIlVua25vd24gLm5ldHJjIGtleXdvcmQgJXMiL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8gPD0gMTYpIHsKKyAgICAgICAgICAgICAgICBjbG9zZShzKTsKKyAgICAgICAgICAgICAg
 ICBzbGVlcCh0aW1vKTsKKyAgICAgICAgICAgICAgICB0aW1vICo9IDI7CisgICAgICAgICAgICAg
 ICAgZ290byByZXRyeTsKKyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHBlcnJvcihocC0+aF9u
 YW1lKTsKKyAgICAgICAgICAgIHJldHVybiAtMTsKKyAgICAgICAgfQorICAgICAgICBpZiAoZmQy
 cCA9PSBOVUxMKSB7CisgICAgICAgICAgICB3cml0ZShzLCAiIiwgMSk7CisgICAgICAgICAgICBw
 b3J0ID0gMDsKKyAgICAgICAgfSBlbHNlIHsKKyAgICAgICAgICAgIGNoYXIgbnVtWzhdOworICAg
 ICAgICAgICAgaW50IHMyLCBzaW4ybGVuOworCisgICAgICAgICAgICBzMiA9IHNvY2tldChBRl9J
 TkVULCBTT0NLX1NUUkVBTSwgMCk7CisgICAgICAgICAgICBpZiAoczIgPCAwKSB7CisgICAgICAg
 ICAgICAgICAgY2xvc2Uocyk7CisgICAgICAgICAgICAgICAgcmV0dXJuIC0xOworICAgICAgICAg
 ICAgfQorICAgICAgICAgICAgbGlzdGVuKHMyLCAxKTsKKyAgICAgICAgICAgIHNpbjJsZW4gPSBz
 aXplb2YgKHNpbjIpOworICAgICAgICAgICAgaWYgKGdldHNvY2tuYW1lKHMyLCAoc3RydWN0IHNv
 Y2thZGRyICopJnNpbjIsICZzaW4ybGVuKSA8IDAgfHwKKyAgICAgICAgICAgICAgc2luMmxlbiAh
 PSBzaXplb2YgKHNpbjIpKSB7CisgICAgICAgICAgICAgICAgcGVycm9yKCJnZXRzb2NrbmFtZSIp
 OworICAgICAgICAgICAgICAgIGNsb3NlKHMyKTsKKyAgICAgICAgICAgICAgICBnb3RvIGJhZDsK
 KyAgICAgICAgICAgIH0KKyAgICAgICAgICAgIHBvcnQgPSBudG9ocygodV9zaG9ydClzaW4yLnNp
 bl9wb3J0KTsKKyAgICAgICAgICAgIHNwcmludGYobnVtLCAiJXUiLCBwb3J0KTsKKyAgICAgICAg
 ICAgIHdyaXRlKHMsIG51bSwgc3RybGVuKG51bSkrMSk7CisgICAgICAgICAgICB7IGludCBsZW4g
 PSBzaXplb2YgKGZyb20pOworICAgICAgICAgICAgICBzMyA9IGFjY2VwdChzMiwgKHN0cnVjdCBz
 b2NrYWRkciAqKSZmcm9tLCAmbGVuKTsKKyAgICAgICAgICAgICAgY2xvc2UoczIpOworICAgICAg
 ICAgICAgICBpZiAoczMgPCAwKSB7CisgICAgICAgICAgICAgICAgcGVycm9yKCJhY2NlcHQiKTsK
 KyAgICAgICAgICAgICAgICBwb3J0ID0gMDsKKyAgICAgICAgICAgICAgICBnb3RvIGJhZDsKKyAg
 ICAgICAgICAgICAgfQorICAgICAgICAgICAgfQorICAgICAgICAgICAgKmZkMnAgPSBzMzsKKyAg
 ICAgICAgfQorICAgICAgICB3cml0ZShzLCBuYW1lLCBzdHJsZW4obmFtZSkgKyAxKTsKKyAgICAg
 ICAgLyogc2hvdWxkIHB1YmxpYyBrZXkgZW5jeXB0IHRoZSBwYXNzd29yZCBoZXJlICovCisgICAg
 ICAgIHdyaXRlKHMsIHBhc3MsIHN0cmxlbihwYXNzKSArIDEpOworICAgICAgICB3cml0ZShzLCBj
 bWQsIHN0cmxlbihjbWQpICsgMSk7CisgICAgICAgIGlmIChyZWFkKHMsICZjLCAxKSAhPSAxKSB7
 CisgICAgICAgICAgICBwZXJyb3IoKmFob3N0KTsKKyAgICAgICAgICAgIGdvdG8gYmFkOworICAg
 ICAgICB9CisgICAgICAgIGlmIChjICE9IDApIHsKKyAgICAgICAgICAgIHdoaWxlIChyZWFkKHMs
 ICZjLCAxKSA9PSAxKSB7CisgICAgICAgICAgICAgICAgd3JpdGUoMiwgJmMsIDEpOworICAgICAg
 ICAgICAgICAgIGlmIChjID09ICdcbicpCisgICAgICAgICAgICAgICAgICAgIGJyZWFrOworICAg
 ICAgICAgICAgfQorICAgICAgICAgICAgZ290byBiYWQ7CisgICAgICAgIH0KKyAgICAgICAgcmV0
 dXJuIHM7CiBiYWQ6Ci0JaWYgKHBvcnQpCi0JCSh2b2lkKSBjbG9zZSgqZmQycCk7Ci0JKHZvaWQp
 IGNsb3NlKHMpOwotCXJldHVybiAoLTEpOworICAgICAgICBpZiAocG9ydCkKKyAgICAgICAgICAg
 IGNsb3NlKCpmZDJwKTsKKyAgICAgICAgY2xvc2Uocyk7CisgICAgICAgIHJldHVybiAtMTsKIH0K
 
 ------=_Part_14701_30557979.1214024836491--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806210510.m5L5A4AT039615>