cgroup-info: check if user.slice is valid before accessing value
Prevent hitting `panic: runtime error: index out of range [1] with length 1` while performing `podman info` when unexpected values for user.slice is found. [NO TESTS NEEDED] Signed-off-by: Aditya Rajan <arajan@redhat.com>
This commit is contained in:
		
							parent
							
								
									68481539a4
								
							
						
					
					
						commit
						bd64039278
					
				| 
						 | 
					@ -231,8 +231,11 @@ func getCgroupPathForCurrentProcess() (string, error) {
 | 
				
			||||||
	for s.Scan() {
 | 
						for s.Scan() {
 | 
				
			||||||
		text := s.Text()
 | 
							text := s.Text()
 | 
				
			||||||
		procEntries := strings.SplitN(text, "::", 2)
 | 
							procEntries := strings.SplitN(text, "::", 2)
 | 
				
			||||||
 | 
							// set process cgroupPath only if entry is valid
 | 
				
			||||||
 | 
							if len(procEntries) > 1 {
 | 
				
			||||||
			cgroupPath = procEntries[1]
 | 
								cgroupPath = procEntries[1]
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if err := s.Err(); err != nil {
 | 
						if err := s.Err(); err != nil {
 | 
				
			||||||
		return cgroupPath, err
 | 
							return cgroupPath, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue