# Extended 5.18 — FilePlugin macOS: strncpy(lastPath, unixPath, MAXPATHLEN) no NUL

Bug ref      : pharo.md §5.18
Severity     : MEDIUM (downstream readers of lastPath walk past)
File         : extracted/plugins/FilePlugin/src/osx/sqUnixFile.c
Lines (HEAD) : 143

## Problem

```c
strncpy(lastPath, unixPath, MAXPATHLEN);
```

Standard strncpy non-termination footgun.

## Fix

```diff
diff --git a/extracted/plugins/FilePlugin/src/osx/sqUnixFile.c b/extracted/plugins/FilePlugin/src/osx/sqUnixFile.c
index 6669dcccb..3bf8d926f 100644
--- a/extracted/plugins/FilePlugin/src/osx/sqUnixFile.c
+++ b/extracted/plugins/FilePlugin/src/osx/sqUnixFile.c
@@ -140,7 +140,10 @@ static int maybeOpenDir(char *unixPath)
     if (lastPathValid)
       closedir(openDir);
     lastPathValid= false;
-    strncpy(lastPath, unixPath, MAXPATHLEN);
+    /* strncpy does not NUL-terminate when the source is exactly MAXPATHLEN
+     * bytes; clamp to MAXPATHLEN-1 and terminate explicitly. */
+    strncpy(lastPath, unixPath, MAXPATHLEN - 1);
+    lastPath[MAXPATHLEN - 1] = '\0';
     if ((openDir= opendir(unixPath)) == 0)
       return false;
     lastPathValid= true;
```

## Test plan

- File path exactly MAXPATHLEN: lastPath is properly terminated.

## Risk notes

- Same pattern as 3.24 and 5.16.
