core: fix malloc size when building filename of upgrade file