소스 검색

[LibOS] Return string length including NULL in getcwd()

getcwd() system call should return string length including
last NULL. Previously, the code had an off-by-one bug.
Isaku Yamahata 5 년 전
부모
커밋
c0df6a5e33
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      LibOS/shim/src/sys/shim_getcwd.c

+ 1 - 1
LibOS/shim/src/sys/shim_getcwd.c

@@ -61,7 +61,7 @@ int shim_do_getcwd (char * buf, size_t len)
     } else if (plen + 1 > len) {
         ret = -ERANGE;
     } else {
-        ret = plen;
+        ret = plen + 1;
         memcpy(buf, path, plen + 1);
     }
     return ret;