[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
strdup()s and other fixes/suggestions
I believe most of the following are correct. Please let me know of any
that aren't. Sorry in advance to anyone's time I waste over incorrect
observations.
lib/libcurses/tinfo/comp_hash.c, revision 1.6 contains:
266: name_table[n].nte_name = strdup(list[column]);
and it doesn't seem to be checked:
282: _nc_make_hash_table(name_table, hash_table);
_nc_make_hash_table(table, hash_table):
81: hashvalue = hash_function(table[i].nte_name);
hash_function(string):
113: while (*string) {
------------------------------------------------------------------------
sbin/init/init.c, revision 1.33 contains:
920: sp->se_window = strdup(typ->ty_window);
921: sp->se_window_argv = construct_argv(sp->se_window);
(in construct_argv(char *command)):
825: char **argv = (char **) malloc(((strlen(command) + 1) / 2 + 1)
------------------------------------------------------------------------
sbin/mount/mount.c, revision 1.33 contains:
free(NULL):
675: if (s0)
676: free(s0);
uncasted malloc():
665: char *cp;
...
669: if ((cp = malloc(i)) == NULL)
------------------------------------------------------------------------
sbin/ping6/ping6.c, revision 1.56 may report a usage error when it runs
out of memory:
588: target = nigroup(argv[argc - 1]);
589: if (target == NULL) {
590: usage();
because nigroup(name) may end with:
2672: return strdup(hbuf);
------------------------------------------------------------------------
usr.bin/column/column.c, revision 1.10 contains:
in input(fp):
285: list[entries++] = strdup(buf);
Flow controls from input(stdin) or input(argv[i]) to c_columnate():
144: for (chcnt = col = 0, lp = list;; ++lp) {
145: chcnt += printf("%s", *lp);
------------------------------------------------------------------------
usr.bin/lex/flex.1, revision 1.13 contains:
932: char *yycopy = strdup( yytext )
------------------------------------------------------------------------
usr.bin/rup/rup.c, revision 1.18 contains:
148: rup_data[rup_data_idx].host = strdup(host);
which looks like it might turn into:
122: return strcmp(d1->host, d2->host);
------------------------------------------------------------------------
usr.bin/sectok/cyberflex.c, revision 1.25 contains:
130: s2 = strdup(s);
131: s = getpass("Re-enter passphrase: ");
132: if (strcmp(s, s2)) {
------------------------------------------------------------------------
usr.bin/talk/get_names.c, revision 1.13 contains:
95: names = strdup(argv[1]);
96: for (cp = names; *cp && !strchr("@:!.", *cp); cp++)
------------------------------------------------------------------------
usr.bin/tic/tic.c, revision 1.27 contains:
1042: zero = strdup(zero);
1043: CHECK_SGR(1, enter_standout_mode);
953:#define CHECK_SGR(num,name) check_sgr(tp, zero, num, name, #name)
in check_sgr(tp, zero, ...):
939: if (test != 0) {
940: if (PRESENT(cap)) {
...
945: } else if (strcmp(test, zero)) {
------------------------------------------------------------------------
usr.bin/tn3270/sys_curses/system.c, revision 1.15 contains:
641: keyname = strdup("/tmp/apiXXXXXXXXXX");
642: if ((fd = mkstemp(keyname)) == -1) {
and:
647: keyname = strdup(sockNAME);
...
693: if (strlen(sockNAME) > (sizeof sockNAME-(10+strlen(keyname)))) {
------------------------------------------------------------------------
usr.bin/window/ttinit.c, revision 1.10 contains:
97: wwterm = strdup(_nc_first_name(cur_term->type.term_names));
...
116: for (tp = tt_tab; tp->tt_name != 0; tp++)
117: if (strncmp(tp->tt_name, wwterm, tp->tt_len) == 0)
------------------------------------------------------------------------
usr.sbin/dhcp/dhclient/dhclient.c, revision 1.27 contains a typo?
1933: error ("script_init:n no memory for environment
initialization");
------------------------------------------------------------------------
- Jared