@@ -177,11 +177,16 @@ func (ch *ContainerdHandler) getPrimaryPidAndNS(ctx context.Context, containerID
177177 pidNS := 0
178178 mntNS := 0
179179
180- if data , e := os .Readlink (filepath .Join (cfg .GlobalCfg .ProcFsMount , pidStr , "/ns/pid" )); e == nil {
181- fmt .Sscanf (data , "pid:[%d]\n " , & pidNS )
180+ if data , err := os .Readlink (filepath .Join (cfg .GlobalCfg .ProcFsMount , pidStr , "/ns/pid" )); err == nil {
181+ if _ , err := fmt .Sscanf (data , "pid:[%d]\n " , & pidNS ); err != nil {
182+ return 0 , 0 , 0 , fmt .Errorf ("failed to parse pid namespace from %q: %w" , data , err )
183+ }
182184 }
183- if data , e := os .Readlink (filepath .Join (cfg .GlobalCfg .ProcFsMount , pidStr , "/ns/mnt" )); e == nil {
184- fmt .Sscanf (data , "mnt:[%d]\n " , & mntNS )
185+
186+ if data , err := os .Readlink (filepath .Join (cfg .GlobalCfg .ProcFsMount , pidStr , "/ns/mnt" )); err == nil {
187+ if _ , err := fmt .Sscanf (data , "mnt:[%d]\n " , & mntNS ); err != nil {
188+ return 0 , 0 , 0 , fmt .Errorf ("failed to parse mount namespace from %q: %w" , data , err )
189+ }
185190 }
186191
187192 return pid , pidNS , mntNS , nil
0 commit comments