Skip to content

Commit a007c4c

Browse files
author
J. Bruce Fields
committed
nfsd: add get_uint for u32's
I don't think there's a practical difference for the range of values these interfaces should see, but it would be safer to be unambiguous. Signed-off-by: J. Bruce Fields <[email protected]>
1 parent a6d88f2 commit a007c4c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

fs/nfsd/export.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ fsloc_parse(char **mesg, char *buf, struct nfsd4_fs_locations *fsloc)
398398
int migrated, i, err;
399399

400400
/* listsize */
401-
err = get_int(mesg, &fsloc->locations_count);
401+
err = get_uint(mesg, &fsloc->locations_count);
402402
if (err)
403403
return err;
404404
if (fsloc->locations_count > MAX_FS_LOCATIONS)
@@ -456,7 +456,7 @@ static int secinfo_parse(char **mesg, char *buf, struct svc_export *exp)
456456
return -EINVAL;
457457

458458
for (f = exp->ex_flavors; f < exp->ex_flavors + listsize; f++) {
459-
err = get_int(mesg, &f->pseudoflavor);
459+
err = get_uint(mesg, &f->pseudoflavor);
460460
if (err)
461461
return err;
462462
/*
@@ -465,7 +465,7 @@ static int secinfo_parse(char **mesg, char *buf, struct svc_export *exp)
465465
* problem at export time instead of when a client fails
466466
* to authenticate.
467467
*/
468-
err = get_int(mesg, &f->flags);
468+
err = get_uint(mesg, &f->flags);
469469
if (err)
470470
return err;
471471
/* Only some flags are allowed to differ between flavors: */

include/linux/sunrpc/cache.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,22 @@ static inline int get_int(char **bpp, int *anint)
230230
return 0;
231231
}
232232

233+
static inline int get_uint(char **bpp, unsigned int *anint)
234+
{
235+
char buf[50];
236+
int len = qword_get(bpp, buf, sizeof(buf));
237+
238+
if (len < 0)
239+
return -EINVAL;
240+
if (len == 0)
241+
return -ENOENT;
242+
243+
if (kstrtouint(buf, 0, anint))
244+
return -EINVAL;
245+
246+
return 0;
247+
}
248+
233249
/*
234250
* timestamps kept in the cache are expressed in seconds
235251
* since boot. This is the best for measuring differences in

0 commit comments

Comments
 (0)