Explorar el Código

fix out of bounds write for zero length buffer in gethostname

Marc André Tanner hace 7 años
padre
commit
3f6dc30470
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      src/unistd/gethostname.c

+ 1 - 1
src/unistd/gethostname.c

@@ -8,6 +8,6 @@ int gethostname(char *name, size_t len)
 	if (uname(&uts)) return -1;
 	if (len > sizeof uts.nodename) len = sizeof uts.nodename;
 	for (i=0; i<len && (name[i] = uts.nodename[i]); i++);
-	if (i==len) name[i-1] = 0;
+	if (i && i==len) name[i-1] = 0;
 	return 0;
 }