libufdt: Fix stack overflow risk in vendor qsort

Optimize the qsort implementation in libufdt_sysdeps_vendor.c by
recursing on the smaller partition and iterating on the larger
partition. This limits the maximum recursion depth to O(log n)
stack frames, preventing potential stack overflows on large or
adversarial inputs.

Bug: 509980995
Test: Standalone test suite (1M elements, ASan/UBSan/Valgrind passed)
Test: tests/run_tests.sh
Test: tests/run_performance_test.sh
Flag: EXEMPT BUGFIX
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:df9856866b8d8b19058beb8e418c588cd47c60dc
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:3ddb2cd7727cc2b7d0f5b5330aadb93aa21943ba
Merged-In: I260075b5280433ae59b61edef9b30cb6610bd02f
Change-Id: I260075b5280433ae59b61edef9b30cb6610bd02f
1 file changed