Hi Matthias, On 9/30/20 11:04 AM, Matthias Brugger wrote: > On 30/09/2020 17:20, Geoff Levand wrote: >> On 9/30/20 3:36 AM, matthias.bgg@xxxxxxxxxx wrote: >>> --- a/kexec/arch/arm64/include/arch/options.h >>> +++ b/kexec/arch/arm64/include/arch/options.h >>> >>> +static uint64_t find_purgatory_sink(const char *console) >>> +{ >>> + int fd, ret; >>> + char device[255], mem[255]; >>> + struct stat sb; >>> + char buffer[10]; >>> + uint64_t iomem = 0x0; >>> + >>> + if (!console) >>> + return 0; >>> + >>> + ret = snprintf(device, sizeof(device), "/sys/class/tty/%s", console); >>> + if (ret < 0 || ret >= sizeof(device)) { >>> + fprintf(stderr, "snprintf failed: %s\n", strerror(errno)); >>> + return 0; >>> + } >>> + >>> + if (stat(device, &sb) || !S_ISDIR(sb.st_mode)) { >>> + fprintf(stderr, "kexec: %s: No valid console found for %s\n", >>> + __func__, device); >>> + return 0; >>> + } >>> + >>> + snprintf(mem, sizeof(mem), "%s%s", device, "/iomem_base"); >>> + if (ret < 0 || ret >= sizeof(mem)) { >> >> Seems this is is just doing the same check again... >> > > Well we have to check snprintf outcome here again. Also sizeof(device) == sizeof(mem) we could have the case where the first snprintf fits into the 255 character, while the second, where we add the "/iomem_base" does not. > > Or didn't I understand you correctly? You forgot to assign ret a new value, so it's just doing the same thing again... -Geoff _______________________________________________ kexec mailing list kexec@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/kexec