what if section header array does not have enough space for a new section header? your code does not handle that, and corrupts the binary.