Преглед изворни кода

fix broken ttyname[_r] (failure to null-terminate result)

Rich Felker пре 12 година
родитељ
комит
fcfba99503
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      src/unistd/ttyname_r.c

+ 4 - 1
src/unistd/ttyname_r.c

@@ -15,5 +15,8 @@ int ttyname_r(int fd, char *name, size_t size)
 
 	if (l < 0) return errno;
 	else if (l == size) return ERANGE;
-	else return 0;
+	else {
+		name[l] = 0;
+		return 0;
+	}
 }