[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1043238: libpfm4: crashes on initialization on 32bit arm in autopkgtest CI



Hello,

Samuel Thibault, le lun. 07 août 2023 21:29:03 +0200, a ecrit:
> It seems that it is crashing because /proc/cpuinfo is empty, and thus
> pfmlib_getl never allocates a buffer, and the trailing b[i] = '\0' thus
> becomes bogus. The attached patch fixes this in my tests.

Could you upload this patch to Debian? It seems upstream does not really
track merge requests, and in the meanwhile the starpu Debian package
can't migrate to testing due to this crash.

Samuel
Cope with empty /proc/cpuinfo file

--- a/lib/pfmlib_common.c
+++ b/lib/pfmlib_common.c
@@ -791,7 +791,8 @@ pfmlib_getl(char **buffer, size_t *len,
 		if (c == '\n')
 			break;
 	}
-	b[i] = '\0';
+       if (c != EOF)
+               b[i] = '\0';
 	return c != EOF ? 0 : -1;
 }
 
--- a/lib/pfmlib_arm.c
+++ b/lib/pfmlib_arm.c
@@ -97,6 +97,8 @@ pfmlib_getcpuinfo_attr(const char *attr,
 		if (!strncmp(attr, buffer, attr_len))
 			break;
 	}
+       if (!value)
+               goto error;
 	strncpy(ret_buf, value, maxlen-1);
 	ret_buf[maxlen-1] = '\0';
 	ret = 0;

Reply to: