In the rpmvercmp() function in tree/pkg.c, I believe that the condition on line 1313 never evaluates to true, effectively the relevant branch is never reached. 1. The while loop on l1281 ensures that both 'one' and 'two' are alphanumeric: while (*one && *two) { while (*one && !isalnum((guchar)*one)) one++; while (*two && !isalnum((guchar)*two)) two++; /* If we ran to the end of either, we are finished with the loop */ if (!(*one && *two)) break; 2. The code block starting on l1294 always increases str1 at least by one. The initial condition for 'if' is the same as the condition in first 'while' iteration. Effectively, the first while always evaluates to true and str1 is always incremented. if (isdigit((guchar)*str1)) { while (*str1 && isdigit((guchar)*str1)) str1++; while (*str2 && isdigit((guchar)*str2)) str2++; isnum = 1; } else { while (*str1 && isalpha((guchar)*str1)) str1++; 3. Thus, it is impossible for the condition on l1313 to be true, since str1 being always incremented, it can no longer be equal to one. if (one == str1) return -1; /* arbitrary */
Your analysis looks correct, and indeed the actual upstream commit that added it has a comment that this can't happen. http://rpm.org/gitweb?p=rpm.git;a=commitdiff;h=40d26f7b However, I'd rather keep it as I think our divergence from upstream should be as minimal as possible. I have a branch I'd like to push that makes all the formatting and comments exactly the same so I can tell exactly how different we are from upstream rpmvercmp. Since the code isn't hurting anything, I'd like to keep it. I encourage you to take your analysis to the rpm devs, though. I'd be happy to pull that into pkg-config if upstream likes it. http://www.rpm.org/report Thanks.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.