+2008-01-21 Guillem Jover <guillem@debian.org>
+
+ * lib/mlib.c (m_strdup): New function.
+ * lib/dpkg.h (m_strdup): New declaration.
+ * lib/tarfn.c: Include <dpkg.h>.
+ (TarExtractor): Use m_strdup instead of strdup.
+ * lib/database.c (findpackage): Likewise.
+ * lib/myopt.c (myfileopt): Likewise.
+ * dpkg-deb/build.c (getfi): Likewise.
+ * src/configure.c (md5hash): Likewise.
+ * src/help.c (vbuildarglist): Likewis.
+ * src/main.c (execbackend): Likewise.
+ (commandfd): Likewise.
+
2008-01-21 Guillem Jover <guillem@debian.org>
* configure.ac: Bump version to 1.14.17~.
dpkg (1.14.17) UNRELEASED; urgency=low
- *
+ [ Guillem Jover ]
+ * Replace strdup plus error checking usage with a new m_strdup function.
+ Closes: #379028
-- Guillem Jover <guillem@debian.org> Mon, 21 Jan 2008 10:11:55 +0200
fi=(struct _finfo*)malloc(sizeof(struct _finfo));
lstat(fn, &(fi->st));
- fi->fn=strdup(fn+rl+1);
+ fi->fn = m_strdup(fn + rl + 1);
fi->next=NULL;
return fi;
}
struct pkginfo *findpackage(const char *inname) {
struct pkginfo **pointerp, *newpkg;
- char *name = strdup(inname), *p;
+ char *name = m_strdup(inname), *p;
- if (name == NULL)
- ohshite(_("couldn't allocate memory for strdup in findpackage(%s)"),inname);
p= name;
while(*p) { *p= tolower(*p); p++; }
void setcloexec(int fd, const char* fn);
void *m_malloc(size_t);
void *m_realloc(void*, size_t);
+char *m_strdup(const char *str);
int m_fork(void);
void m_dup2(int oldfd, int newfd);
void m_pipe(int fds[2]);
return r;
}
+char *
+m_strdup(const char *str)
+{
+ char *new_str;
+
+ onerr_abort++;
+ new_str = strdup(str);
+ if (!new_str)
+ ohshite(_("failed to allocate memory"));
+ onerr_abort--;
+
+ return new_str;
+}
+
static void print_error_forked(const char *emsg, const char *contextstring) {
fprintf(stderr, _("%s (subprocess): %s\n"), thisname, emsg);
}
if (cip->takesvalue) {
if (!opt) ohshite(_("configuration error: %s needs a value"), linebuf);
if (cip->call) cip->call(cip,opt);
- else *cip->sassignto= strdup(opt);
+ else
+ *cip->sassignto = m_strdup(opt);
} else {
if (opt) ohshite(_("configuration error: %s does not take a value"), linebuf);
if (cip->call) cip->call(cip,NULL);
#include <grp.h>
#include <errno.h>
#include <tarfn.h>
+#include <dpkg.h>
struct TarHeader {
char Name[100];
break;
case SymbolicLink:
memcpy(&symListBottom->h, &h, sizeof(TarInfo));
- if ((symListBottom->h.Name = strdup(h.Name)) == NULL) {
- status = -1;
- errno = 0;
- break;
- }
- if ((symListBottom->h.LinkName = strdup(h.LinkName)) == NULL) {
- free(symListBottom->h.Name);
- status = -1;
- errno = 0;
- break;
- }
+ symListBottom->h.Name = m_strdup(h.Name);
+ symListBottom->h.LinkName = m_strdup(h.LinkName);
if ((symListBottom->next = malloc(sizeof(symlinkList))) == NULL) {
free(symListBottom->h.LinkName);
free(symListBottom->h.Name);
pop_cleanup(ehflag_normaltidy); /* fd= open(cdr.buf) */
close(fd);
} else if (errno==ENOENT) {
- *hashbuf= strdup(NONEXISTENTFLAG);
+ *hashbuf = m_strdup(NONEXISTENTFLAG);
} else {
fprintf(stderr, _("dpkg: %s: warning - unable to open conffile %s for hash: %s\n"),
pkg->name, fn, strerror(errno));
- *hashbuf= strdup("-");
+ *hashbuf = m_strdup("-");
}
}
i=0;
if(bufs[0]) free(bufs[0]);
- bufs[i++]= strdup(scriptname); /* yes, cast away const because exec wants it that way */
+ /* Yes, cast away const because exec wants it that way */
+ bufs[i++] = m_strdup(scriptname);
for (;;) {
assert(i < PKGSCRIPTMAXARGS);
nextarg= va_arg(ap,char*);
if (!nargv)
ohshite(_("couldn't malloc in execbackend"));
- nargv[i] = strdup(cipaction->parg);
- if (!nargv[i])
- ohshite(_("couldn't strdup in execbackend"));
+ nargv[i] = m_strdup(cipaction->parg);
+
i++, offset++;
if (pass_admindir) {
i++, offset++;
/* Copy arguments from argv to nargv. */
- for (; i <= argc; i++) {
- nargv[i] = strdup(argv[i - offset]);
- if (!nargv[i])
- ohshite(_("couldn't strdup in execbackend"));
- }
+ for (; i <= argc; i++)
+ nargv[i] = m_strdup(argv[i - offset]);
+
nargv[i] = NULL;
execvp(cipaction->parg, nargv);
* least.
*/
for(i=1;i<argc;i++)
- if (newargs[i]) newargs[i]=strdup(newargs[i]);
+ if (newargs[i])
+ newargs[i] = m_strdup(newargs[i]);
cipaction= NULL;
myopt((const char *const**)&newargs,cmdinfos);