author | Shawn Ferry <shawn.ferry@oracle.com> |
Mon, 28 Nov 2016 16:54:02 -0800 | |
changeset 7565 | 48aa82a0931f |
parent 7098 | a46c4562925e |
permissions | -rw-r--r-- |
7098
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
1 |
This fix comes from the community, this patch ports the relevant |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
2 |
changes from the upstream 2013-10-10-alpha version which fixed the issue. |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
3 |
--- INIT.2012-08-01.old/src/cmd/ksh93/bltins/cd_pwd.c 2016-06-28 04:05:14.983264679 -0700 |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
4 |
+++ INIT.2012-08-01/src/cmd/ksh93/bltins/cd_pwd.c 2016-06-28 04:12:16.937817270 -0700 |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
5 |
@@ -109,34 +109,20 @@ |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
6 |
if(!oldpwd) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
7 |
oldpwd = path_pwd(shp,1); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
8 |
} |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
9 |
- if(*dir=='.') |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
10 |
+ if(*dir!='/') |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
11 |
{ |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
12 |
- /* test for pathname . ./ .. or ../ */ |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
13 |
- int n=0; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
14 |
- char *sp; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
15 |
- for(dp=dir; *dp=='.'; dp++) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
16 |
+ /* check for leading .. */ |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
17 |
+ char *cp; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
18 |
+ sfprintf(shp->strbuf,"%s",dir); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
19 |
+ cp = sfstruse(shp->strbuf); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
20 |
+ pathcanon(cp, 0); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
21 |
+ if(cp[0]=='.' && cp[1]=='.' && (cp[2]=='/' || cp[2]==0)) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
22 |
{ |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
23 |
- if(*++dp=='.' && (*++dp=='/' || *dp==0)) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
24 |
- n++; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
25 |
- else if(*dp && *dp!='/') |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
26 |
- break; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
27 |
- if(*dp==0) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
28 |
- break; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
29 |
- } |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
30 |
- if(n) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
31 |
- { |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
32 |
- cdpath = 0; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
33 |
- sp = oldpwd + strlen(oldpwd); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
34 |
- while(n--) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
35 |
- { |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
36 |
- while(--sp > oldpwd && *sp!='/'); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
37 |
- if(sp==oldpwd) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
38 |
- break; |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
39 |
- |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
40 |
- } |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
41 |
- sfwrite(shp->strbuf,oldpwd,sp+1-oldpwd); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
42 |
- sfputr(shp->strbuf,dp,0); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
43 |
- dir = sfstruse(shp->strbuf); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
44 |
+ if(!shp->strbuf2) |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
45 |
+ shp->strbuf2 = sfstropen(); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
46 |
+ sfprintf(shp->strbuf2,"%s/%s",oldpwd,cp); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
47 |
+ dir = sfstruse(shp->strbuf2); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
48 |
+ pathcanon(dir, 0); |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
49 |
} |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
50 |
} |
a46c4562925e
23319761 cd going dotty by removing leading periods in dir names
Lijo George<lijo.x.george@oracle.com>
parents:
diff
changeset
|
51 |
rval = -1; |