Skip to content

Commit da93f9c

Browse files
committed
Fix off-by-one error in try_file().
Fix the off-by-one error that could would cause breakage if /etc/env.d/python/config did not end with a trailing newline.
1 parent 0e24599 commit da93f9c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/python-exec-c.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ static int try_file(char* bufp, const char* progname,
110110
rd = fread(bufp, 1, max_len+2, f);
111111
if (rd > 0 && feof(f))
112112
{
113-
if (bufp[rd-2] == '\n')
113+
if (bufp[rd-1] == '\n')
114114
--rd;
115-
bufp[rd-1] = '/';
116-
strcpy(&bufp[rd], progname);
115+
bufp[rd] = '/';
116+
strcpy(&bufp[rd+1], progname);
117117

118118
fclose(f);
119119
return 1;

0 commit comments

Comments
 (0)