From 146200310f31ea493aaa0a8e258605dca51ac450 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sat, 28 Feb 2015 12:12:34 +0000 Subject: [PATCH] * uinfo.cc (pwdgrp::add_line): Return NULL if parsing a line failed. (pwdgrp::add_account_post_fetch): Check return value from add_line and return NULL if add_line returns NULL. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/uinfo.cc | 15 ++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 987e75803..cf1f9a9ca 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-02-28 Corinna Vinschen + + * uinfo.cc (pwdgrp::add_line): Return NULL if parsing a line failed. + (pwdgrp::add_account_post_fetch): Check return value from add_line and + return NULL if add_line returns NULL. + 2015-02-27 Corinna Vinschen * security.cc (alloc_sd): For directories, mark inherited ACEs diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index d9ce9028a..40e960a60 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -574,8 +574,9 @@ pwdgrp::add_line (char *eptr) max_lines * pwdgrp_buf_elem_size); } lptr = eptr; - if ((this->*parse) ()) - curr_lines++; + if (!(this->*parse) ()) + return NULL; + curr_lines++; } return eptr; } @@ -1459,18 +1460,18 @@ get_logon_sid () void * pwdgrp::add_account_post_fetch (char *line, bool lock) { + void *ret = NULL; + if (line) { - void *ret; if (lock) pglock.init ("pglock")->acquire (); - add_line (line); - ret = ((char *) pwdgrp_buf) + (curr_lines - 1) * pwdgrp_buf_elem_size; + if (add_line (line)) + ret = ((char *) pwdgrp_buf) + (curr_lines - 1) * pwdgrp_buf_elem_size; if (lock) pglock.release (); - return ret; } - return NULL; + return ret; } void *