mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Security: Add break judge to smk_import_entry() in security/smack/smack_access.c
@ 2010-03-13 13:25 wzt.wzt
  2010-03-13 19:36 ` Casey Schaufler
  0 siblings, 1 reply; 2+ messages in thread
From: wzt.wzt @ 2010-03-13 13:25 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-security-module, sds, casey

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.

Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>

---
 security/smack/smack_access.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index 0f9ac81..0e064e8 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -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] == '\'') {
-- 
1.6.5.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Security: Add break judge to smk_import_entry() in security/smack/smack_access.c
  2010-03-13 13:25 [PATCH] Security: Add break judge to smk_import_entry() in security/smack/smack_access.c wzt.wzt
@ 2010-03-13 19:36 ` Casey Schaufler
  0 siblings, 0 replies; 2+ messages in thread
From: Casey Schaufler @ 2010-03-13 19:36 UTC (permalink / raw)
  To: wzt.wzt
  Cc: linux-kernel, linux-security-module, Stephen Smalley, Casey Schaufler

wzt.wzt@gmail.com 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.
>
> Signed-off-by: Zhitong Wang <zhitong.wangzt@alibaba-inc.com>
>   
Nacked-by: Casey Schaufler <casey@schaufler-ca.com>
> ---
>  security/smack/smack_access.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
> index 0f9ac81..0e064e8 100644
> --- a/security/smack/smack_access.c
> +++ b/security/smack/smack_access.c
> @@ -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.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-13 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-13 13:25 [PATCH] Security: Add break judge to smk_import_entry() in security/smack/smack_access.c wzt.wzt
2010-03-13 19:36 ` Casey Schaufler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome