Bug 7274 - Segmentation fault in putgrent when calling groupadd
Summary: Segmentation fault in putgrent when calling groupadd
Status: NEW
Alias: None
Product: uClibc
Classification: Unclassified
Component: Other (show other bugs)
Version: 0.9.34
Hardware: PC Other
: P5 major
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-23 08:43 UTC by Mykola
Modified: 2014-07-23 08:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Proposed patch (371 bytes, patch)
2014-07-23 08:49 UTC, Mykola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mykola 2014-07-23 08:43:33 UTC
In release mode calling of 'groupadd  -o -g 11 cdrom' caught segmentation fault in putgrent function, /libc/pwd_grp/pwd_grp.c, line 806
if (!*m) {
  if (__fputc_unlocked('\n', f) >= 0) {
    rv = 0;
  }
  break;
}
The reason is in null value of 'm' pointer.
Proposed fix:
diff --git a/libc/pwd_grp/pwd_grp.c b/libc/pwd_grp/pwd_grp.c
index 0e7c7f7..2361b9b 100644
--- a/libc/pwd_grp/pwd_grp.c
+++ b/libc/pwd_grp/pwd_grp.c
@@ -803,7 +803,7 @@ int putgrent(const struct group *__restrict p, FILE *__restrict f)
 			m = p->gr_mem;
 
 			do {
-				if (!*m) {
+				if (!m || !*m) {
 					if (__fputc_unlocked('\n', f) >= 0) {
 						rv = 0;
 					}
Comment 1 Mykola 2014-07-23 08:49:07 UTC
Created attachment 5516 [details]
Proposed patch