From: Todd C. Miller Date: Thu, 3 Sep 2009 13:21:43 +0000 (+0000) Subject: Actually. qsort is fine since most versions fal back to a cheaper X-Git-Tag: SUDO_1_7_3~315 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=568c99b099dc0fb0ccab146d5ac8c61438653091;p=sudo Actually. qsort is fine since most versions fal back to a cheaper sort when the number of elements to sort is small (like in our case). --- diff --git a/script.c b/script.c index cb90938e9..0b69fef7f 100644 --- a/script.c +++ b/script.c @@ -268,24 +268,21 @@ script_duplow(fd) /* sort fds so we can dup them safely */ for (i = 0; i < 5; i++) indices[i] = i; - /* XXX - qsort is overkill for this */ qsort(indices, 5, sizeof(int), fdcompar); /* Move pty master/slave and session fds to low numbered fds. */ - if (def_script) { - for (i = 0; i < 5; i++) { - j = indices[i]; - if (script_fds[j] != fd) { + for (i = 0; i < 5; i++) { + j = indices[i]; + if (script_fds[j] != fd) { #ifdef HAVE_DUP2 - dup2(script_fds[j], fd); + dup2(script_fds[j], fd); #else - close(fd); - dup(script_fds[j]); - close(script_fds[j]); + close(fd); + dup(script_fds[j]); + close(script_fds[j]); #endif - } - script_fds[j] = fd++; } + script_fds[j] = fd++; } return(fd); }