Commit 8274e453 authored by Moe Jette's avatar Moe Jette
Browse files

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.
parent e2bc04b5
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment