Changes in trunk/src/sh_utils.c [29:20]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_utils.c
r29 r20 189 189 } 190 190 191 int sh_util_hidesetup(c onst char * c)191 int sh_util_hidesetup(char * c) 192 192 { 193 193 int i; … … 205 205 SL_ENTER(_("sh_util_strdup")); 206 206 207 SH_VALIDATE_NE(str, NULL);208 209 len = sl_strlen(str);210 p = SH_ALLOC (len + 1);211 (void) sl_strlcpy (p, str, len+1);212 207 if (str != NULL) 208 { 209 len = sl_strlen(str); 210 p = SH_ALLOC (len + 1); 211 (void) sl_strlcpy (p, str, len+1); 212 } 213 213 SL_RETURN( p, _("sh_util_strdup")); 214 214 } … … 224 224 ret = *str; 225 225 226 SH_VALIDATE_NE(ret, NULL); 226 if (ret == NULL) { 227 SL_RETURN(ret, _("sh_util_strsep")); 228 } 227 229 228 230 for (c = *str; *c != '\0'; c++) { … … 644 646 static int sigtype = TYPE_HMAC; 645 647 646 int sh_util_sigtype (c onst char * c)648 int sh_util_sigtype (char * c) 647 649 { 648 650 SL_ENTER(_("sh_util_sigtype")); … … 955 957 char * key; 956 958 char * path; 957 char * outpath = NULL;959 char * outpath; 958 960 unsigned char * image = NULL; 959 961 long s = 0; … … 961 963 long ii, k = 0; 962 964 UINT32 * h1; 963 char * new = NULL;965 char * new; 964 966 965 967 if (0 != sl_is_suid()) … … 997 999 fprintf(stderr, 998 1000 _("ERROR: no path to executable given\n Argument must be 'key@path'\n")); 999 free(new);1000 1001 _exit (EXIT_FAILURE); 1001 1002 /*@notreached@*/ … … 1004 1005 else 1005 1006 path = &new[j]; 1006 1007 len = strlen(path) + 1 + 4;1008 1007 /*@-usedef@*/ 1009 if (NULL == (outpath = malloc( len)))1008 if (NULL == (outpath = malloc(strlen(path) + 1 + 4))) 1010 1009 goto bail_mem; 1011 1010 /*@-usedef@*/ 1012 sl_snprintf (outpath, len, _("%s.out"), path); 1011 /*@-bufferoverflowhigh@*/ 1012 sprintf (outpath, _("%s.out"), path); /* known to fit */ 1013 /*@+bufferoverflowhigh@*/ 1013 1014 1014 1015 fp = sl_open_read(path, SL_NOPRIV); … … 1017 1018 fprintf(stderr, 1018 1019 _("ERROR: cannot open %s for read (errnum = %ld)\n"), path, fp); 1019 free(new); free (outpath);1020 1020 _exit (EXIT_FAILURE); 1021 1021 /*@notreached@*/ … … 1028 1028 fprintf(stderr, 1029 1029 _("ERROR: cannot open %s (errnum = %ld)\n"), outpath, fout); 1030 free(new); free (outpath);1031 1030 _exit (EXIT_FAILURE); 1032 1031 /*@notreached@*/ … … 1069 1068 (void) sl_close (fout); 1070 1069 printf(_("new file %s written\n"), outpath); 1071 free(new); free (outpath); free(image);1072 1070 _exit (EXIT_SUCCESS); 1073 1071 /*@notreached@*/ … … 1078 1076 fprintf(stderr, 1079 1077 _("ERROR: old key not found\n")); 1080 free(new); free (outpath); free(image);1081 1078 _exit (EXIT_FAILURE); 1082 1079 /*@notreached@*/ … … 1087 1084 fprintf(stderr, 1088 1085 _("ERROR: out of memory\n")); 1089 if (new) free(new);1090 if (outpath) free (outpath);1091 if (image) free (image);1092 1086 _exit (EXIT_FAILURE); 1093 1087 /*@notreached@*/ … … 1335 1329 static unsigned char sh_obscure_index[256]; 1336 1330 1337 int sh_util_obscure_ok (c onst char * str)1331 int sh_util_obscure_ok (char * str) 1338 1332 { 1339 1333 unsigned long i; 1340 char * endptr = NULL;1341 1342 SL_ENTER(_("sh_util_obscure_ ok"));1334 char * endptr = str; 1335 1336 SL_ENTER(_("sh_util_obscure_ex")); 1343 1337 1344 1338 if (0 == sl_strncmp("all", str, 3)) … … 1348 1342 sh_obscure_index[i] = (unsigned char)1; 1349 1343 } 1350 SL_RETURN(0, _("sh_util_obscure_ ok"));1344 SL_RETURN(0, _("sh_util_obscure_ex")); 1351 1345 } 1352 1346 … … 1355 1349 sh_obscure_index[i] = (unsigned char)0; 1356 1350 } 1357 1358 i = strtoul (str, &endptr, 0);1359 if (i > 255)1360 {1361 SL_RETURN(-1, _("sh_util_obscure_ok"));1362 }1363 sh_obscure_index[i] = (unsigned char)1;1364 if (*endptr == ',')1365 ++endptr;1366 1351 1367 1352 while (*endptr != '\0') … … 1370 1355 if (i > 255) 1371 1356 { 1372 SL_RETURN(-1, _("sh_util_obscure_ ok"));1357 SL_RETURN(-1, _("sh_util_obscure_ex")); 1373 1358 } 1374 1359 sh_obscure_index[i] = (unsigned char)1; … … 1376 1361 ++endptr; 1377 1362 } 1378 SL_RETURN(0, _("sh_util_obscure_ ok"));1363 SL_RETURN(0, _("sh_util_obscure_ex")); 1379 1364 } 1380 1365 1381 1366 int sh_util_obscurename (ShErrLevel level, char * name_orig, int flag) 1382 1367 { 1383 unsigned char * name = (unsigned char *)name_orig;1368 char * name = name_orig; 1384 1369 char * safe; 1385 1370 unsigned int i; … … 1393 1378 while (*name != '\0') 1394 1379 { 1395 if ( (*name) > 0x7F || (*name)== '"' || (*name) == '\t' ||1380 if ( (*name) == '"' || (*name) == '\t' || 1396 1381 (*name) == '\b' || (*name) == '\f' || 1397 1382 (*name) == '\n' || (*name) == '\r' || … … 1577 1562 } else if (!isgraph ((int) *p)) { /* not printable */ 1578 1563 /*@-bufferoverflowhigh -formatconst@*/ 1579 /* flawfinder: ignore */1580 1564 sprintf(oct, format, '\\', /* known to fit */ 1581 1565 (unsigned char) *p);
Note:
See TracChangeset
for help on using the changeset viewer.