Browse Source

be careful when using mktemp, don't pass in string literal

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 4 years ago
parent
commit
7f5fef0f61
1 changed files with 2 additions and 2 deletions
  1. 2 2
      sys/src/regress/libc/readoffset.c

+ 2 - 2
sys/src/regress/libc/readoffset.c

@@ -5,7 +5,7 @@
 // Plan 9 pread had a bug where the channel offset we updated during a call to
 // pread - this shouldn't have happened.
 
-static char *tmpfilename = nil;
+static char tmpfilename[128] = "readoffsetXXXXX";
 
 static void
 rmtmp(void)
@@ -33,7 +33,7 @@ preadn(int fd, char *buf, int32_t nbytes, int64_t offset)
 void
 main(int argc, char *argv[])
 {
-	tmpfilename = mktemp("readoffset");
+	mktemp(tmpfilename);
 	int fd = create(tmpfilename, ORDWR, 0666);
 	if (fd < 0) {
 		print("FAIL: couldn't create file: %s\n", tmpfilename);