Research
Skip Research Menus
Research MenuSecurity Enhanced Linux What's New Frequently Asked Questions Background Documents License Download Participating Mail List Archives Remaining Work Contributors Related Work Press Releases Information Assurance Research NIARL In-house Research Areas Mathematical Sciences Program Sabbaticals Computer & Information Sciences Research Technology Transfer Advanced Computing Advanced Mathematics Communications & Networking Information Processing Microelectronics Other Technologies Technology Fact Sheets Publications Related Links |
SELinux Mailing ListRe: [PATCH] libselinux-3
From: Stephen Smalley <sds_at_epoch.ncsc.mil>
Date: 24 Oct 2003 17:09:33 -0400
@@ -366,13 +366,13 @@ if (!ptr) return -1; plen = strlen(ptr); - if (buf[plen-1] == '\n') + if (plen > 1 && buf[plen-1] == '\n') buf[plen-1] = 0; I believe that the original code is correct, and that the patch introduces a minor bug. If the file is empty, ptr will be NULL and the !ptr test will catch it. Hence, plen should always be at least 1. Further, your test for plen > 0 means that you won't clear the newline in the case where the file contains only a newline and nothing else, i.e. plen == 1 and buf[0] == '\n'. @@ -23,11 +23,11 @@ if (ret < 0 && errno == ERANGE) { char *newbuf; - size = fgetxattr(fd, XATTR_NAME_SELINUX, NULL, 0); - if (size < 0) + ret = fgetxattr(fd, XATTR_NAME_SELINUX, NULL, 0); + if (ret < 0) goto out; - size++; + size = ret + 1; newbuf = realloc(buf, size); if (!newbuf) goto out; As with the earlier patch for the *getfilecon functions, this one introduces a bug. Look at the result of this patch when the realloc fails; since ret is reset by your change, the out path will not treat it as an error, and the caller will be returned garbage without any indication that the call actually failed. -- Stephen Smalley <sds@epoch.ncsc.mil> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with the words "unsubscribe selinux" without quotes as the message.Received on Fri 24 Oct 2003 - 17:09:42 EDT |
|
Date Posted: Jan 15, 2009 | Last Modified: Jan 15, 2009 | Last Reviewed: Jan 15, 2009 |