Set errno to 0 before getpwuid() and check it afterwards
This commit is contained in:
		
							parent
							
								
									ba3acfc0dc
								
							
						
					
					
						commit
						6a55128354
					
				
							
								
								
									
										5
									
								
								slock.c
								
								
								
								
							
							
						
						
									
										5
									
								
								slock.c
								
								
								
								
							| 
						 | 
					@ -65,8 +65,11 @@ getpw(void) { /* only run as root */
 | 
				
			||||||
	const char *rval;
 | 
						const char *rval;
 | 
				
			||||||
	struct passwd *pw;
 | 
						struct passwd *pw;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						errno = 0;
 | 
				
			||||||
	pw = getpwuid(getuid());
 | 
						pw = getpwuid(getuid());
 | 
				
			||||||
	if(!pw)
 | 
						if (errno)
 | 
				
			||||||
 | 
							die("slock: getpwuid: %s\n", strerror(errno));
 | 
				
			||||||
 | 
						else if (!pw)
 | 
				
			||||||
		die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
 | 
							die("slock: cannot retrieve password entry (make sure to suid or sgid slock)\n");
 | 
				
			||||||
	endpwent();
 | 
						endpwent();
 | 
				
			||||||
	rval =  pw->pw_passwd;
 | 
						rval =  pw->pw_passwd;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue