Skip to contentSkip to conversation

Security: Add break judge to smk_import_entry() in security/smack/smack_access.c

PATCH NAK [email protected] 2 participants 2 messages Mar 13, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Security: Add break judge to smk_import_entry() in security/smack/smack_access.c

In smk_import_entry(), smack[i] = '\0' was set if found = 1, so:
if (found)

	smack[i] = '\0';

No need to continue again, just can break the loop.

---
 security/smack/smack_access.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
security/smack/smack_access.c +1 -1
index 0f9ac81..0e064e8 100644
@@ -318,7 +318,7 @@ struct smack_known *smk_import_entry(const char *string, int len)
 
 	for (i = 0, found = 0; i < SMK_LABELLEN; i++) {
 		if (found)
-			smack[i] = '\0';
+			break;
 		else if (i >= len || string[i] > '~' || string[i] <= ' ' ||
 			 string[i] == '/' || string[i] == '"' ||
 			 string[i] == '\\' || string[i] == '\'') {
Signature · 1 line
1.6.5.3
maintainer Nacked-by on v1 1/1 NAK
#1 lore raw
Quoted 7 lines · [email protected] wrote:

In smk_import_entry(), smack[i] = '\0' was set if found = 1, so:
if (found)

	smack[i] = '\0';

No need to continue again, just can break the loop.

Quoted 10 lines
---
 security/smack/smack_access.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
security/smack/smack_access.c +0 -0
index 0f9ac81..0e064e8 100644

security/smack/smack_access.c struct smack_known *smk_import_entry(const char *string, int len) · line 324

Quoted 8 lines
security/smack/smack_access.c +1 -1
@@ -318,7 +318,7 @@ struct smack_known *smk_import_entry(const char *string, int len)
 
 	for (i = 0, found = 0; i < SMK_LABELLEN; i++) {
 		if (found)
-			smack[i] = '\0';
+			break;
 		else if (i >= len || string[i] > '~' || string[i] <= ' ' ||
 			 string[i] == '/' || string[i] == '"' ||
 			 string[i] == '\\' || string[i] == '\'') {

The intention of this code is to fill the label. Yes, I could zero the target in advance and break here but would that be significantly better? I don't see that it would be. In any case, the change you suggest would not suffice by itself.

Are you looking for a real project to work on? I could suggest a thing or two that would be much more welcome than these attempts at pointless code change.