Patch from Gerrit: 09_hostlist__hostlist_deranged_string.diff
hostlist_deranged_string(): test for overflow This builds upon the preceding patch, exploiting that hostrange_to_string() * returns >= 0 when it has terminated the string with '\0', where either - n == 0 and it has not written anything or - it has written at most n > 0 characters, indicated by returning n-1 >= 0; * returns a negative value to indicate truncation. Hence hostrange_deranged_string() changed as follows: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * added 'len < n' as loop condition, to catch the case 'n == 0' (also exploiting that NUL-termination is only needed on error); * separator now is inserted after all non-first elements (to avoid having to undo the last separator); * as in preceding patch, replaced 'truncated' variable by a jump label.
Please register or sign in to comment