support reading of negative numbers for rlimit values
authorMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 30 Oct 2008 06:13:37 +0000 (06:13 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 30 Oct 2008 06:13:37 +0000 (06:13 +0000)
src/planetlab.c

index 90ba4dd..db9c430 100644 (file)
@@ -356,8 +356,13 @@ pl_get_limits(const char *context, struct sliver_resources *slr)
        buf[len-1]='\0';
        len --;
       }
        buf[len-1]='\0';
        len --;
       }
-      if ( (r->type == TYPE_LONG) && isdigit(*buf)) {
-       *r->limit = atoi(buf);
+      if (r->type == TYPE_LONG) {
+       int val;
+       char *res=0;
+       errno=0;
+       val = strtol(buf,&res,0);
+       if ( !( (val==0 && res) || (errno!=0) ) )
+         *r->limit = val;
       } else if ( (r->type == TYPE_PERS) && isalpha(*buf)) {
        unsigned long int res;
        res = vc_str2personalitytype(buf,len);
       } else if ( (r->type == TYPE_PERS) && isalpha(*buf)) {
        unsigned long int res;
        res = vc_str2personalitytype(buf,len);