On 03/11/2011 12:01 PM, Ivana Hutarova Varekova wrote:
> Fix the problem described in 
> https://bugzilla.redhat.com/show_bug.cgi?id=667968
> cgclassify accepts invalid non-numeric arguments, testcase:
> 
> $ cgclassify -g cpu:/ xxx; echo $?
> 0
> 
> 
> Signed-off-by: Ivana Hutarova Varekova <varek...@redhat.com>
Acked-By: Jan Safranek <jsafr...@redhat.com>

> ---
> 
>  src/tools/cgclassify.c |   10 +++++++++-
>  1 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/src/tools/cgclassify.c b/src/tools/cgclassify.c
> index fcad4b2..cdd6a9d 100644
> --- a/src/tools/cgclassify.c
> +++ b/src/tools/cgclassify.c
> @@ -106,6 +106,7 @@ int main(int argc, char *argv[])
>       int flag = 0;
>       struct cgroup_group_spec *cgroup_list[CG_HIER_MAX];
>       int c;
> +     char *endptr;
>  
>  
>       if (argc < 2) {
> @@ -151,7 +152,14 @@ int main(int argc, char *argv[])
>       }
>  
>       for (i = optind; i < argc; i++) {
> -             pid = (uid_t) atoi(argv[i]);
> +             pid = (uid_t) strtol(argv[i], &endptr, 10);
> +             if (endptr[0] != '\0') {
> +                     /* the input argument was not a number */
> +                     fprintf(stderr, "Error: %s is not valid pid.\n",
> +                             argv[i]);
> +                     exit_code = 2;
> +                     continue;
> +             }
>  
>               if (flag)
>                       ret = cgroup_register_unchanged_process(pid, flag);
> 
> 
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d
> _______________________________________________
> Libcg-devel mailing list
> Libcg-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/libcg-devel


------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to