diff --git a/vfs/ChangeLog b/vfs/ChangeLog index 5f006020b..64d93db8e 100644 --- a/vfs/ChangeLog +++ b/vfs/ChangeLog @@ -1,6 +1,11 @@ +2002-06-25 Pavel Roskin + + * vfs.c: Add protection against NULL strings to all is_*() + functions. + 2002-06-21 Andrew V. Samoilov - * smbfs.c: Undefine PACKAGE_BUGREPORT, PACKAGE_NAME, + * smbfs.c: Undefine PACKAGE_BUGREPORT, PACKAGE_NAME, PACKAGE_STRING, PACKAGE_TARNAME and PACKAGE_VERSION before including "samba/include/config.h" to prevent warnings. (smbfs_init): Set DEBUGLEVEL to 0. @@ -17,7 +22,7 @@ * Makefile.am (SAMBA_DIST): Remove tests/ftruncate.c * samba/tests/ftruncate.c: Removed. - * samba/configure.in: Don't check if ftruncate() can + * samba/configure.in: Don't check if ftruncate() can extend a file. 2002-06-06 Andrew V. Samoilov @@ -38,7 +43,7 @@ 2002-05-22 Andrew V. Samoilov * xdirentry.h (vfs_s_fh.u.ftp): Add append field. - (vfs_s_data.file_store): Change second argument + (vfs_s_data.file_store): Change second argument to (vfs_s_fh *fh). * direntry.c (vfs_s_close): Adjust. * fish.c (file_store): Likewise. diff --git a/vfs/vfs.c b/vfs/vfs.c index 1e8811176..9af318fd5 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -1382,18 +1382,25 @@ vfs_split_text (char *p) static int is_num (int idx) { - if (!columns [idx] || columns [idx][0] < '0' || columns [idx][0] > '9') + char *column = columns[idx]; + + if (!column || column[0] < '0' || column[0] > '9') return 0; + return 1; } static int -is_dos_date(char *str) +is_dos_date (char *str) { - if (strlen(str) == 8 && str[2] == str[5] && strchr("\\-/", (int)str[2]) != NULL) - return (1); + if (!str) + return 0; - return (0); + if (strlen (str) == 8 && str[2] == str[5] + && strchr ("\\-/", (int) str[2]) != NULL) + return 1; + + return 0; } static int @@ -1402,12 +1409,15 @@ is_week (char *str, struct tm *tim) static const char *week = "SunMonTueWedThuFriSat"; char *pos; - if((pos=strstr(week, str)) != NULL){ - if(tim != NULL) - tim->tm_wday = (pos - week)/3; - return (1); + if (!str) + return 0; + + if ((pos = strstr (week, str)) != NULL) { + if (tim != NULL) + tim->tm_wday = (pos - week) / 3; + return 1; } - return (0); + return 0; } static int @@ -1415,13 +1425,16 @@ is_month (char *str, struct tm *tim) { static const char *month = "JanFebMarAprMayJunJulAugSepOctNovDec"; char *pos; - - if((pos=strstr(month, str)) != NULL){ - if(tim != NULL) - tim->tm_mon = (pos - month)/3; - return (1); + + if (!str) + return 0; + + if ((pos = strstr (month, str)) != NULL) { + if (tim != NULL) + tim->tm_mon = (pos - month) / 3; + return 1; } - return (0); + return 0; } static int @@ -1429,41 +1442,47 @@ is_time (char *str, struct tm *tim) { char *p, *p2; - if ((p=strchr(str, ':')) && (p2=strrchr(str, ':'))) { + if (!str) + return 0; + + if ((p = strchr (str, ':')) && (p2 = strrchr (str, ':'))) { if (p != p2) { - if (sscanf (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, &tim->tm_sec) != 3) - return (0); - } - else { + if (sscanf + (str, "%2d:%2d:%2d", &tim->tm_hour, &tim->tm_min, + &tim->tm_sec) != 3) + return 0; + } else { if (sscanf (str, "%2d:%2d", &tim->tm_hour, &tim->tm_min) != 2) - return (0); + return 0; } - } - else - return (0); - - return (1); + } else + return 0; + + return 1; } -static int is_year(char *str, struct tm *tim) +static int is_year (char *str, struct tm *tim) { long year; - if (strchr(str,':')) - return (0); + if (!str) + return 0; - if (strlen(str)!=4) - return (0); + if (strchr (str, ':')) + return 0; - if (sscanf(str, "%ld", &year) != 1) - return (0); + if (strlen (str) != 4) + return 0; + + if (sscanf (str, "%ld", &year) != 1) + return 0; if (year < 1900 || year > 3000) - return (0); + return 0; tim->tm_year = (int) (year - 1900); - return (1); + return 1; } /*